Adapt functionality based on customer tags or other conditions
Adapt cart functionalities via window variables (custom code)
Last updated
While EliteCart functionality is generally set up within the app, you can adapt functionality based on conditions like
- the page your customer is on
- tags a logged-in customer might have
- day of the week, time of day
- locale of the customer
- location of the customer
- any other variables you can set via liquid
These are the variables you can set:
<script>
window.eliteCartOverwrites = {
disableCart?: boolean; // disables cart. theme cart will show instead. always disables tracking too
disableAnalytics?: boolean; // disables view and add to cart tracking
hideUpsells?: boolean;
hideAddons?: boolean;
hideBanner?: boolean;
hideRewardBar?: boolean;
hideReward1?: boolean;
hideReward2?: boolean;
hideReward3?: boolean;
};
</script>
Example Wholesale Tag
Below is a liquid example code that disables EliteCart completely (your theme's cart or cart page will show instead) if a customer with tag "wholesale" is on the website. Note that the customer must be logged into their account.
{% assign isWholesaleCustomer = false %}
{% for tag in customer.tags %}
{% assign lowerTag = tag | downcase %}
{% if lowerTag == "wholesale" %}
{% assign isWholesaleCustomer = true %}
{% endif %}
{% endfor %}
{% if isWholesaleCustomer == true %}
<script>
window.eliteCartOverwrites = {
disableCart: true,
};
</script>
{% endif %}
Above code should be placed in your theme.liquid file, just before the closing of the body tag.
Various Use Cases
1. Hide EliteCart for Wholesale Customers
Condition: Check if the logged-in customer is a wholesale customer.
Action: Hide whole cart, or specific parts of the cart.
Use the code example provided above to check for the “wholesale” tag and set the EliteCart variables accordingly.
2. Hide “Log in to get free shipping” banner for logged in customers
Condition: Check if a customer is logged-in.
Action: Hide the banner.
4. Hide a banner that says "next day delivery" on Fridays, Saturdays and Sundays & from 4pm to midnight every day.
Condition: Use shopify liquid to check the day of the week. Beware of timezones if you sell internationally. See also here.
Action: Hide the banner
Still stuck?
Chat with us and we'll help you get your cart live. Or email contact@elitecart.app.