Last active
July 5, 2020 02:03
-
-
Save ardeearam/4617bbf33f27ada317b6213c279f87d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| theme.ShippingBar = (function(theme) { | |
| var bar = document.querySelector('.announcement-bar'); | |
| if(bar) | |
| { | |
| var promote_txt = bar.dataset.promote; | |
| var unlocked_txt = bar.dataset.unlocked; | |
| var treshold = bar.dataset.treshold; | |
| } | |
| function update() | |
| { | |
| if(bar) | |
| { | |
| $.getJSON('/cart.js').then( | |
| function(cart) { | |
| var value_left = treshold - cart.total_price; | |
| var value_left_money = theme.Currency.formatMoney(value_left,theme.moneyFormat); | |
| if(value_left <= 0){ | |
| bar.innerHTML = '<p class="announcement-bar__message">' + unlocked_txt + '</p>'; | |
| } | |
| else{ | |
| bar.innerHTML = '<p class="announcement-bar__message">' + promote_txt.replace('[value]',value_left_money) + '</p>'; | |
| } | |
| } | |
| ); | |
| } | |
| } | |
| return { update:update } | |
| }) (theme); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment