All Collections
Developers
Enable checkout methods using customer tag
Enable checkout methods using customer tag

Show or hide pickup, delivery or shipping depending on your customers tags

Clemency Farmer avatar
Written by Clemency Farmer
Updated over a week ago

You can hide or show checkout methods to customers based on their tags.


Requirements


Enable pickup by customer tag

  1. Within Zapiet - Pickup + Delivery, click Settings, then click Developers.

  2. 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"]);
    }

  3. 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

  1. Within Zapiet - Pickup + Delivery, click Settings, then click Developers.

  2. 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"]);
    }


  3. 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

  1. Within Zapiet - Pickup + Delivery, click Settings, then click Developers.

  2. 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"]);
    }

  3. 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!

Did this answer your question?