Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- blackMonday: function(){
- var cart = this.cart.model,
- $discountNotice = $('.discount-notice > .discount-container');
- var currentTier;
- var newTier = currentTier;
- // Remove the cookie and show the notice if hidden
- function clearDiscountCookie() {
- document.cookie = "no_discount_notice=false";
- if ( !$('.discount-notice').hasClass('visible') ) {
- $('.discount-notice').addClass('visible');
- }
- }
- // Listen to your cart when it's calling for you, listen to your cart there's nothing else you can do!
- this.listenTo(cart, "change", function(){
- // Less than 99
- if(cart.get('total_price') < 9900){
- $discountNotice.html('<p>Your Cart Total is <span>' + Shopify.formatMoney(cart.get('total_price')) + '</span> - spend ' + (Shopify.formatMoney(9900 - cart.get('total_price'))) + ' more to receive <span>$15 off!</span></p>');
- currentTier = 0;
- if ( newTier != currentTier ) {
- clearDiscountCookie();
- }
- }
- // Between 99 and 150
- else if ( cart.get('total_price') >= 9900 && cart.get('total_price') < 15000 ){
- $discountNotice.html('<p>Hoorah! Receive $15 by using the discount code <span>H15</span> at the checkout — or spend ' + (Shopify.formatMoney(15000 - cart.get('total_price'))) + ' more for <span>$25 off!</span></p>');
- currentTier = 1;
- if ( newTier != currentTier ) {
- clearDiscountCookie();
- }
- }
- // Between 150 and 300
- else if ( cart.get('total_price') >= 15000 && cart.get('total_price') < 30000 ){
- $discountNotice.html('<p>Look at you go! Receive $25 by the using discount code <span>H25</span> at the checkout — or spend ' + (Shopify.formatMoney(30000 - cart.get('total_price'))) + ' more for <span>$60 off!</span></p>');
- currentTier = 2;
- if ( newTier != currentTier ) {
- clearDiscountCookie();
- }
- }
- // Over 300
- else if ( cart.get('total_price') >= 30000 ){
- $discountNotice.html('<p>Great success! Use discount code <span>H60</span> at the checkout for <span>$60 off!</span></p>');
- currentTier = 3;
- if ( newTier != currentTier ) {
- clearDiscountCookie();
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement