Created
January 23, 2026 09:46
-
-
Save KittenCodes/7d448e5c28992a3086e4de3f78312dde to your computer and use it in GitHub Desktop.
Solid Affiliate QR Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Include this snippet in your WordPress page builder --> | |
| <div id="affiliate-qr-container"> | |
| <!-- Render affiliate link using the shortcode --> | |
| <span id="affiliate-link" style="display:none;">[solid_affiliate_current_affiliate_link]</span> | |
| <!-- Placeholder for the QR Code --> | |
| <canvas id="affiliate-qr-code"></canvas> | |
| </div> | |
| <!-- Load QR code library via CDN --> | |
| <script src="https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js"></script> | |
| <script> | |
| document.addEventListener("DOMContentLoaded", function() { | |
| // Get the affiliate link | |
| const affiliateLinkElement = document.getElementById("affiliate-link"); | |
| const affiliateLink = affiliateLinkElement ? affiliateLinkElement.textContent.trim() : ""; | |
| //debugger; | |
| if (affiliateLink) { | |
| // Generate the QR code | |
| QRCode.toCanvas(document.getElementById("affiliate-qr-code"), affiliateLink, function(error) { | |
| if (error) console.error("Error generating QR code:", error); | |
| }); | |
| } else { | |
| console.error("Affiliate link not found or invalid."); | |
| } | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment