All Collections
Zapiet - Pickup + Delivery
Advanced
Hiding checkout methods by product tag
Hiding checkout methods by product tag
Disable or enable pickup, delivery, or shipping for certain groups of products based on the product tag
Jelizaveta avatar
Written by Jelizaveta
Updated over a week ago

Using product tags, you can hide checkout methods by adding a code snippet.

For example, if you have certain products that are only available for pickup and you would like to hide the other method(s) such as delivery and/or shipping.

If you would like to show all methods to your customers and only display an error message when they are not available, you can use our native Conditional activation feature.

Please reach out to us at [email protected]—we’ll be happy to implement this for you. Only proceed if you are comfortable editing code yourself.



The placement of the code will depend on the widget version your store is on.

Online store 2.0

If you are using our widget on Online store 2.0, you will need to add the code in Zapiet - Pickup + Delivery > Settings > Developers, under Custom scripts.

Versions 7.1.2 and older

If you are using our widget on an older version of our app (that has our files), you will need to add the code in your storepickup-addons.liquid file.

Please contact us on [email protected], so we can check if you're eligible for an update to Online store 2.0!


Tag products

Read more about tags and how to add them to your products in the Shopify Add tags article.


Online Store 2.0

Add this code snippet in Zapiet - Pickup + Delivery > Settings > Developers, under Custom scripts.

function hasTag(tag) {
var products = ZapietWidgetConfig.products;
for (var i = 0; i < products.length; i++) {
var tags = products[i].tags;
for (var j = 0; j < tags.length; j++) {
if (tags[j] == tag) {
return true;
}
}
}
return false;
}
if (hasTag("Delivery Only")) {
Zapiet.show("delivery");
Zapiet.hide(["shipping", "pickup"]);
}
else if (hasTag("Pickup Only")) {
Zapiet.show("pickup");
Zapiet.hide(["shipping", "delivery"]);
}

The second half of this code needs to be modified to fit your needs—it has two parts, when you need to use two different tags.

The first part will only show delivery, and hide shipping and pickup for items tagged with “Delivery Only”.

To modify the code:

  • Replace “Delivery Only” with the tag you have created

    • Tags are case sensitive, so make sure that the value matches the tag exactly.

  • Replace "delivery" with the method you want to show

  • Replace (["shipping", "pickup"]) with the methods you'd like to hide

if (hasTag("Delivery Only")) {
Zapiet.show("delivery");
Zapiet.hide(["shipping", "pickup"]);

The second part will show only pickup for items with "Pickup only" tag, and hide shipping and delivery. If you need to add multiple tags too:

  • Replace "Pickup Only" with the tag you have created

    • Tags are case sensitive, so make sure that the value matches the tag exactly.

  • Replace "pickup" with the method you want to show

  • Replace (["shipping", "delivery"]) with the methods you'd like to hide

} else if (hasTag("Pickup Only")) {
Zapiet.show("pickup");
Zapiet.hide(["shipping", "delivery"]);
}

Note

If you are showing or hiding more than one method, it needs to be an array.

  • If you're using an array, use parentheses and brackets

([shipping”, “delivery”])
  • If you're using only one method, use parentheses only

(“pickup”)

Versions 7.1.2 and older

Add this code snippet in the storepickup-addons file in your theme files.

{% for item in cart.items %}    
{% if item.product.tags contains 'Pickup Only' %}
{% capture disable_shipping %} true {% endcapture %}
{% capture disable_delivery %} true {% endcapture %}
{% elsif item.product.tags contains 'Delivery Only' %}
{% capture disable_pickups %} true {% endcapture %}
{% capture disable_shipping %} true {% endcapture %}
{% endif %}
{% endfor %}

This code will hide delivery and shipping methods for items with "Pickup Only" tag and hide the pickup and shipping methods for items with the "Delivery Only" tag.

You can modify this code to suit your needs and add the tags you have created. Tags are case sensitive, so make sure that the value matches the tag exactly.

  • Disable pickup

    {% capture disable_pickups %} true {% endcapture %}  
  • Disable delivery

    {% capture disable_delivery %} true {% endcapture %}   
  • Disable shipping

    {% capture disable_shipping %} true {% endcapture %} 

Troubleshooting

If the changes are not visible at the cart page, make sure that:

  • The tags added in the code snippets match the tag on your product exactly (they are case sensitive)

  • You have jQuery added in your theme files for the Online store 2.0 version. If not, you can add it on top of the cart file in your theme files:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
Did this answer your question?