Add Cart Saved

Highlighted
New Member
5 0 0

Hi People! I have a problem.

I'm working with Narrative theme and in it theme when you change the quantity automatically change "subtotal price" (It theme doesn't use a buttom of "update cart"). 

I wrote the code to add Regular price and save price but when someone click add to cart a product in product page it work good but when someone be in cart page and change quantity the subtotal price (It don't modify it) is update and the Regular price and Save price (I wrote it)  aren't update....... If I refresh page (F5) is update else it isn't update.

my code is (the last four row are standard of the theme):

HELP PLEASE!!!

 

{% assign total_saving = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price > item.variant.price %}
{% assign saving = item.variant.compare_at_price | minus: item.variant.price | times: item.quantity %}
{% assign total_saving = saving | plus: total_saving %}
{% endif %}
{% endfor %}
       
{% assign total_price = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price > item.variant.price %}
{% assign tprice = item.variant.compare_at_price | times: item.quantity %}
{% assign total_price = tprice | plus: total_price %}
{% endif %}
{% endfor %}
          
          <div class="cart-subtotal"> 
          <span class="cart-subtotal__title h4">Price</span>
  		<span class="cart-subtotal__price"><strike>{{ total_price | money }}</strike></span></span>
          </div>
          <div class="cart-subtotal"> 
          <span class="cart-subtotal__title h4">Saving</span>
          <span class="cart-subtotal__price"="color:#EDA415">{{ total_saving | money }}</span>
          </div>
            <div class="cart-subtotal">            
            <span class="cart-subtotal__title h4">Subtotal</span>
            <span class="cart-subtotal__price" data-cart-subtotal><span id="bk-cart-subtotal-price"><span class="wh-original-cart-total"><span class='wh-original-price'>{{ cart.total_price | money }}</span></span><span class="wh-cart-total"></span><div class="additional-notes"><span class="wh-minimums-note"></span><span class="wh-extra-note"></span></div></span></span>
          </div>
0 Likes