-
-
Save heywin/708ec0e9e100d6e6a0134e3ec67b1f1a to your computer and use it in GitHub Desktop.
Shopify - Apply Discount / Coupon / Promo Code on cart page
This file contains 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
<div class="cart-promo"> | |
<input type="text" id="devPromo" placeholder="Discount Code"> | |
<a href="/checkout?discount=none" id="redemDevPromo" class="btn" style="margin-bottom:0px">Apply</a></div> | |
<script>$(document).ready(function() { | |
//listen to the promo button click | |
$('#redemDevPromo').on('click', | |
function(event) { | |
//disable the button event | |
event.preventDefault(); | |
//write the url format | |
var theUrl = '/checkout?discount='; | |
//grab the discount code from the input | |
var theDiscount = $('#devPromo').val(); | |
//full url to redirect to checkout with promo code | |
var toRedirect = theUrl + theDiscount; | |
console.log(toRedirect); | |
//redirect | |
window.location.href = toRedirect; | |
}); | |
}); | |
</script> |
I added to cart.liquid, looks great. When click Apply, go to checkout but coupon shows none.
Any update?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cart.liquid文件中添加