Skip to content

Instantly share code, notes, and snippets.

@KittenCodes
Created January 23, 2026 09:46
Show Gist options
  • Select an option

  • Save KittenCodes/7d448e5c28992a3086e4de3f78312dde to your computer and use it in GitHub Desktop.

Select an option

Save KittenCodes/7d448e5c28992a3086e4de3f78312dde to your computer and use it in GitHub Desktop.
Solid Affiliate QR Code
<!-- 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