cartjs icon indicating copy to clipboard operation
cartjs copied to clipboard

Update Cart.total_price minus: 5000 in custom code

Open vemundeldegard opened this issue 8 years ago • 1 comments

Hi!

Loving cartjs, been using it for a long time on my stores. I am working on a count down to free shipping based on the cart.total.price. It should be pretty simple, but I can't get the cart.total_price to be updated based on cart update.

{% assign some_number = 50000 | minus: cart.total_price %}
<div data-cart-view>
<span class="cart-count" rv-show="cart.total_price | gt 50000">You qualify for free delivery!</span>
<span class="cart-count" rv-show="cart.total_price | lt 50000">If you spend <span id="counter">{{ 50000 | minus: cart.total_price | money }}</span> more you will qualify for free delivery.</span>
</div>

How may I update this so I don't have to refresh to see changes? I have tried something like this:

<span rv-html="minus: 50000 | cart.total_price | money_without_trailing_zeros"></span>

vemundeldegard avatar Feb 14 '18 20:02 vemundeldegard

Hey I think you need to remove the colon after minus, which isn't intuitive since that's how it is in liquid I'm doing the same thing and it's like this and it works

<div id="free-shipping-msg-over-50" rv-if="cart.total_price | gt 5000"><p>Congratulations. Your shipping is free.</p></div>

<div id="free-shipping-msg-under-50" rv-if="cart.total_price | lt 5000"><p>Free US shipping over $50 — ${5000 | minus cart.total_price} to go</p></div>

joeldmyers avatar Feb 21 '18 19:02 joeldmyers