Linking email sign up with coupon code

Linking email sign up with coupon code

Pyimk
Explorer
50 2 3

Hello, I am using Craft theme.

This email section is default one from shopify admin.
This is not email pop-up. I have already contacted service team from Vital, where i use email pop-up app and they say it is not related with them. It is true though.

I want to be it like when someone type in their email and subscribe, I want the disocount code to show up.

I have already created discount code for this.

If it is impossible, is there any alternate way to do it?

Screenshot 2024-07-14 at 9.45.39 PM.png

 ill

Replies 3 (3)

EcomGraduates
Shopify Partner
795 68 114

To show the discount code immediately after someone subscribes using the default Shopify email signup form, you'll need to customize the form a bit with some code. Here’s a way to do it:

  1. Edit the theme code: Go to your Shopify admin, click on "Online Store," then "Themes." Click "Actions" next to your current theme and select "Edit code."

  2. Find the form: Look for the file that contains your email signup form. It could be in a file like footer.liquid or a section file related to the footer.

  3. Add JavaScript for the discount: You’ll need to add some JavaScript to display the discount code upon form submission. Here’s an example of what the code could look like:

 

<script>
document.addEventListener('DOMContentLoaded', function() {
  var form = document.querySelector('form'); // Adjust the selector to match your form
  form.addEventListener('submit', function(event) {
    event.preventDefault(); // Prevent the default form submission
    var discountCode = 'YOUR_DISCOUNT_CODE'; // Replace with your actual discount code
    alert('Thank you for subscribing! Use code ' + discountCode + ' for 10% off your first order.');
    form.submit(); // Now submit the form
  });
});
</script>

 

 

  1. Insert the script: Place this script at the bottom of your form’s file, just before the closing </body> tag or within a script block in the HTML.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



EcomGraduates
Shopify Partner
795 68 114

Add JavaScript for the discount: You’ll need to add some JavaScript to display the discount code upon form submission. Here’s an example of what the code could look like:

<script>
document.addEventListener('DOMContentLoaded', function() {
  var form = document.querySelector('form'); // Adjust the selector to match your form
  form.addEventListener('submit', function(event) {
    event.preventDefault(); // Prevent the default form submission
    var discountCode = 'YOUR_DISCOUNT_CODE'; // Replace with your actual discount code
    alert('Thank you for subscribing! Use code ' + discountCode + ' for 10% off your first order.');
    form.submit(); // Now submit the form
  });
});
</script>

 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



Pyimk
Explorer
50 2 3

Screenshot 2024-07-21 at 1.16.36 AM.png

It is not working.
the place where i put is in section> email sign up banner liquid
I do not k now what adjust the selector to match my form mean so i just put h2 which i saw on a youtube.