Created
May 26, 2019 21:57
-
-
Save git-willie/7b5facb3e64fc7488ccfcfaf169c6a47 to your computer and use it in GitHub Desktop.
Dynamic sales motivator message
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
// Display motivator message | |
ShopifyAPI.saleMotivator = function(cart, cart_motivator_goal, motivator_msg_selector) { | |
var cart_subtotal = parseFloat(cart.total_price / 100).toFixed(2); | |
var cart_motivator_goal = cart_motivator_goal; | |
var cart_motivator_goal_remaining = parseFloat(cart_motivator_goal - cart_subtotal).toFixed(2); | |
var motivator_msg = motivator_msg_selector; | |
if (cart_subtotal == 0) { | |
motivator_msg.html('FREE SHIPPING ON ORDERS OVER $' + cart_motivator_goal); | |
} else { | |
if (cart_subtotal >= cart_motivator_goal) { | |
motivator_msg.html('AWESOME, YOU NOW QUALIFY FOR FREE SHIPPING!'); | |
} else { | |
motivator_msg.html('NICE - JUST SPEND $' + cart_motivator_goal_remaining + ' MORE AND GET FREE SHIPPING!'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment