You can hide or show checkout methods to customers based on their tags.
Requirements
Customers must have tags added in Shopify.
Take a look at Creating and using tags in Shopify for more information.You must be using Zapiet - Pickup + Delivery widget version 1 or 2.
If you're on a legacy version, contact us on chat and we would be happy to install the update for you! Which version of the widget am I using?
Enable pickup by customer tag
Within Zapiet - Pickup + Delivery, click Settings, then click Developers.
In Custom scripts, add the code below.
You can modify the code based on your store needs. This example code will hide pickup for all customers, unless the customer is logged in and the customer has the tag "Pickup Allowed".
function customerHasTag(tag) {
if (
!ZapietCachedSettings.customer ||
!ZapietCachedSettings.customer.tags
) {
return false;
}
var tags = ZapietCachedSettings.customer.tags;
for (var i = 0; i < tags.length; i++) {
if (tags[i] == tag) {
return true;
}
}
return false;
}
if (customerHasTag("Pickup Allowed")) {
Zapiet.show("pickup");
} else {
Zapiet.hide("pickup");
}You can hide or show multiple methods by adding the methods into an array.
In this example code, if a customer has the tag “Pickup Only”, then both delivery and shipping will be hidden, but if they have the tag “Shipping Only” then only shipping will show.
if (customerHasTag("Pickup Only")) {
Zapiet.show("pickup");
Zapiet.hide(["delivery", "shipping"]);
}
else if (customerHasTag("Shipping Only")) {
Zapiet.show("Shipping");
Zapiet.hide(["pickup", "delivery"]);
}Click Save.
Pickup will now be hidden by default to all customers, unless the customer is logged in and has the "Pickup Allowed" tag.
Enable delivery by customer tag
Within Zapiet - Pickup + Delivery, click Settings, then click Developers.
In Custom scripts, add the code below.
You can modify the code based on your store needs. This example code will hide delivery to all customers, unless the customer is logged in and the customer has the tag "Delivery allowed".
function customerHasTag(tag) {
if (
!ZapietCachedSettings.customer ||
!ZapietCachedSettings.customer.tags
) {
return false;
}
var tags = ZapietCachedSettings.customer.tags;
for (var i = 0; i < tags.length; i++) {
if (tags[i] == tag) {
return true;
}
}
return false;
}
if (customerHasTag("Delivery Allowed")) {
Zapiet.show("delivery");
} else {
Zapiet.hide("delivery");
}You can hide or show multiple methods by adding the methods into an array.
In this example code, if a customer has the tag "Delivery Only", then both pickup and shipping will be hidden, but if they have the tag "Pickup Only" then only pickup will show.
if (customerHasTag("Delivery Only")) {
Zapiet.show("delivery ");
Zapiet.hide(["shipping", "pickup"]);
}
else if (customerHasTag("Pickup Only")) {
Zapiet.show("pickup");
Zapiet.hide(["shipping", "delivery"]);
}
Click Save.
Delivery will now be hidden by default to all customers, unless the customer is logged in and has the "Delivery Allowed" tag.
Enable shipping by customer tag
Within Zapiet - Pickup + Delivery, click Settings, then click Developers.
In Custom scripts, add the code below.
You can modify the code based on your store needs. This example code will hide shipping to all customers, unless the customer is logged in and the customer has the tag "Shipping allowed".
function customerHasTag(tag) {
if (
!ZapietCachedSettings.customer ||
!ZapietCachedSettings.customer.tags
) {
return false;
}
var tags = ZapietCachedSettings.customer.tags;
for (var i = 0; i < tags.length; i++) {
if (tags[i] == tag) {
return true;
}
}
return false;
}
if (customerHasTag("Shipping Allowed")) {
Zapiet.show("shipping");
} else {
Zapiet.hide("shipping");
}You can hide or show multiple methods by adding the methods into an array.
In this example code, if a customer has the tag "Shipping Only", then both delivery and pickup will be hidden, but if they have the tag "Pickup Only" then only pickup will show.
if (customerHasTag("Shipping Only")) {
Zapiet.show("shipping");
Zapiet.hide(["delivery", "pickup"]);
}
else if (customerHasTag("Pickup Only")) {
Zapiet.show("pickup");
Zapiet.hide(["shipping", "delivery"]);
}Click Save.
Shipping will now be hidden by default to all customers, unless the customer is logged in and has the "Shipping Allowed" tag.
If you have any issues implementing the code, contact us on chat and we would be happy to help!