gumroad Pop up code

Integrate Gumroad into Your Website: Easy Step-by-Step Guide

Learn how to integrate Gumroad into your website with our detailed guide. Improve your sales process by providing a familiar and efficient buying experience for your customers.

requirements

install Wpcode Plugin on your WordPress site.

You need to create 2 code Snippets, one for JS and the other for CSS.

To redirect to checkout :

https://store.gumroad.com/l/PRODUCT-ID?wanted=true

JS Code

Copy these codes and make sure to follow the instructions in our youtube video.

document.addEventListener("DOMContentLoaded", function() {
const popup = document.getElementById("popup");
const iframe = document.getElementById("gumroadIframe");
const close = document.querySelector(".close");
const buttons = document.querySelectorAll(".checkoutButton"); // Select all buttons with the class 'checkoutButton'

buttons.forEach(function(button) {
button.addEventListener("click", function() {
const gumroadCheckoutUrl = this.getAttribute("data-url"); // Get the URL from the data-url attribute
iframe.src = gumroadCheckoutUrl; // Set the iframe source to the Gumroad checkout URL
popup.style.display = "block"; // Show the popup
});
});

close.addEventListener("click", function() {
popup.style.display = "none"; // Hide the popup
iframe.src = ""; // Clear the iframe source to stop the checkout process
});

window.addEventListener("click", function(event) {
if (event.target === popup) {
popup.style.display = "none"; // Hide the popup if clicked outside
iframe.src = ""; // Clear the iframe source
}
});
});

CSS Code

Copy these codes and make sure to follow the instructions in our youtube video.

/* Styles for the popup */
.popup {
display: none; /* Hidden by default */
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(8 7 7 / 83%); /* Darker background with more opacity */
}

.popup-content {
background-color: #F4F4F1;
margin: 10% auto;
padding: 20px;
border-radius: 8px;
border: 2px solid #000
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
width: 90%;
max-width: 600px;
position: relative;
}

.close {
color: #333;
float: right;
font-size: 24px;
font-weight: bold;
cursor: pointer;
transition: color 0.3s ease;
}

.close:hover,
.close:focus {
color: #ff4d4d; /* A soft red color for hover effect */
text-decoration: none;
}

iframe {
border: none;
border-radius: 4px; /* Rounded corners for the iframe */
}

@media screen and (max-width: 600px) {
.popup-content {
width: 95%;
}
}

HTML Code

Copy these codes and make sure to follow the instructions in our youtube video.

---- Code without image

<!-- Button for Product  -->
<button class="checkoutButton" data-url="https://store.gumroad.com/l/PRODUCT-ID?wanted=true">Buy Product </button>

<div id="popup" class="popup">
<div class="popup-content">
<span class="close">&times;</span>
<iframe id="gumroadIframe" src="" frameborder="0" width="100%" height="500px"></iframe>
</div>
</div>

---- Code with image

<!-- Button -->

<button class="checkoutButton" data-url="https://store.gumroad.com/l/PRODUCT-ID?wanted=true" style="background-color: transparent;">
<img src="https://www.yourwebsite.com/wp-content/uploads/2024/08/buy-now.webp" alt="Buy Product" style="width: 200px; height: auto;">
</button>

<div id="popup" class="popup">
<div class="popup-content">
<span class="close">&times;</span>
<iframe id="gumroadIframe" src="" frameborder="0" width="100%" height="500px"></iframe>
</div>
</div>

Video Tutorials

Play Video about تعلم التجارة الإلكترونية
Play Video about تعلم التجارة الإلكترونية
Play Video about تعلم التجارة الإلكترونية