Help with Free Shipping Bar - exclude virtual products \ gift cards

Hi Everyone

We are getting ready to migrate our store to Shopify .

We are running the premium ‘Empire’ theme , this has a free shipping bar where you can set a free shipping limit however it seems that it just runs on every product whether shipping is applicable or not - virtual products \ gift cards. the theme devs dont want to know.

Is there anyone able to have a quick look at the Liquid snippet and see if excluding certain products is an easy fix? - Cheers D.

Snippet :

{% comment %}
@param_1 context {String}
The snippet context.
{% endcomment %}

{%- if settings.enable_free_shipping_bar
and settings.free_shipping_minimum_amount != blank
and cart.currency.iso_code == shop.currency
-%}
{%- liquid
assign multiplier = 100
assign currencies_without_subunits = ‘JPY,KRW,ISK,CLP,PYG,CRC,TWD,RWF,UGX’
if currencies_without_subunits contains shop.currency
assign multiplier = 1
endif

assign free_shipping_minimum_amount = settings.free_shipping_minimum_amount | times: multiplier
assign free_shipping_remainder = free_shipping_minimum_amount | minus: cart.items_subtotal_price
assign free_shipping_progress = cart.items_subtotal_price | times: 100 | divided_by: free_shipping_minimum_amount | at_most: 100
-%}

{%- liquid assign amount = free_shipping_remainder | money if cart.items_subtotal_price == 0 and template.name == 'cart' echo 'cart.free_shipping_bar.free_shipping_empty_html' | t: amount: amount elsif free_shipping_remainder > 0 echo 'cart.free_shipping_bar.free_shipping_ineligible_html' | t: amount: amount else echo 'cart.free_shipping_bar.free_shipping_eligible_html' | t endif -%}

{%- endif -%}

Hey @NorthumbrianTin ,

thanks for dropping the snippet in — and yes, you can tweak this to exclude virtual products like gift cards from the free shipping bar calculation. Shopify doesn’t directly flag “virtual” products, but there are a couple of common ways to identify them:

Here’s what to change in your snippet:

You’ll want to:

  • Loop through cart.items

  • Filter out any items that are virtual

  • Recalculate items_subtotal_price accordingly

Modified Liquid Snippet

Replace this:

assign free_shipping_remainder = free_shipping_minimum_amount | minus: cart.items_subtotal_price
assign free_shipping_progress = cart.items_subtotal_price | times: 100 | divided_by: free_shipping_minimum_amount | at_most: 100

With this:

{%- assign adjusted_subtotal = 0 -%}
{%- for item in cart.items -%}
  {%- unless item.product.gift_card or item.product.tags contains 'virtual' or item.product.tags contains 'no-shipping' -%}
    {%- assign adjusted_subtotal = adjusted_subtotal | plus: item.line_price -%}
  {%- endunless -%}
{%- endfor -%}

{%- assign free_shipping_remainder = free_shipping_minimum_amount | minus: adjusted_subtotal -%}
{%- assign free_shipping_progress = adjusted_subtotal | times: 100 | divided_by: free_shipping_minimum_amount | at_most: 100 -%}

This will:

  • Exclude gift cards

  • Exclude any products tagged virtual or no-shipping

  • Still show the free shipping bar if applicable

Let me know if you want the full snippet pasted back together with the changes — or if you want to filter by product type instead of tags. Happy to tweak it more!

Hi Rajweb

Wow thank so much for your reply :slightly_smiling_face:

Any chance you could paste the full snippet with changes?

That would be fantastic - thanks so much!

Cheers D.

Julia Thank you so much !

Wonderful explanation thank you

Cheers D.

Absolutely, happy to help!
I’ll paste the full snippet with the changes shortly. In the meantime, please feel free to reach out to me anytime if you need anything else.

Thanks again!

Fantastic!! - Thank you so much :slightly_smiling_face:

Cheers D.