Re: Adding Custom Message When Coupon Code is Applied - Shopify Plus

Adding Custom Message When Coupon Code is Applied - Shopify Plus

metagals
Shopify Partner
29 1 0

I am trying to make a message appear when a coupon code is applied at checkout in the spot indicated below.Screen Shot 2021-11-17 at 1.32.03 PM.png

 

Support advised me that I need to add Javascript to the checkout.liquid layout file and that the javascript should watch the discount code element on the front end for changes and append the message when needed. 

 

Does anyone have experience with this or any ideas on how to get started with the javascript? 

Replies 2 (2)

ashukasma
Shopify Partner
47 11 15

Yes, You can add following JS in checkout page

(function($) {
$(document).on("page:load page:change", function() {
// Add your custom code for discount here
});
})(Checkout.$);

 

Shopify Expert - https://experts.shopify.com/lucentinnovation
metagals
Shopify Partner
29 1 0

That seems to just show the message on checkout page load instead of when the coupon code is applied.