You are X away from free shipping notification in cart preview

troy10
Tourist
30 0 1

I'm trying to get my cart preview to show "You are X away from free shipping" however I don't think that it's pulling that there's a new product being added to the cart so it just stays the original shipping rate. 

This is the code I am using for the cart page but the cart preview (popup when item added to cart) doesn't calculate it correctly. How do I fix this for the preview? 

{% assign shipping_value = 8500 %}
{% assign cart_total = cart.total_price %}
{% assign shipping_value_left = shipping_value | minus: cart_total%}
<p class="shipping-savings-message">
  {% if shipping_value_left > 0 %}
  You are {{ shipping_value_left | money }} away from free shipping!
  {% else %}
    You've qualify for free shipping!
  {% endif %}

www.riotsociety.com

0 Likes
Sergey
Shopify Partner
19 0 4

I'm not sure whether it's possible to achieve using just code in Liquid, but we developed an app which does it as a popup – https://apps.shopify.com/free-shipping-popup.

Built more than 10 public Shopify apps for clients, with partners and our own – https://asoft.co
0 Likes
klatchdesign
Tourist
3 0 1

I'm guessing it's the top line that says 8500%. Mine is for $50 or more. Mine works. It looks like this: 

{% assign shipping_value = 5000 %}
{% assign cart_total = cart.total_price %}
{% assign shipping_value_left = shipping_value | minus: cart_total %}

<p class="shipping-savings-message">
{% if shipping_value_left > 0 %}
You are {{ shipping_value_left | money }} away from free shipping! <a href="/collections/all">Continue shopping</a> to add more products to your cart and receive free shipping for orders over $100.
{% else %}
You've got free shipping!
{% endif %}
</p>

0 Likes