Custom liquid
Write your own Liquid snippet to decide access, with customer, cart, product, and storefront variables.
The Custom liquid rule lets you write your own Liquid code snippet to decide whether a visitor gets access. It's the most flexible rule in the app — anything you can express as a Liquid condition against the customer, their cart, the current product or collection, or the storefront itself, you can use to gate content — but it's also the one rule where a mistake in the snippet has real consequences, covered below.
How it works
Custom liquid is an action-based rule, so it doesn't have an If/Unless toggle. Instead, the app runs your snippet for each visitor and reads its final result. The result must be exactly true or false (surrounding whitespace is ignored): true passes the rule and false fails it. Other output, such as true - customer is eligible, is not a valid result. Your snippet has access to the same kind of data a Shopify theme would have about the current visitor and page.
Adding the rule
Open the lock, click the Unlock rules tab, and choose Custom liquid from the Condition type dropdown.

The code editor
The rule's condition type opens a dedicated Liquid code editor with syntax highlighting, autocomplete, and real-time syntax validation — errors in your Liquid are flagged directly in the editor as you type, before you even save.

Available variables
The editor exposes a library of variables you can insert, grouped by what they describe:
Customer
customer, customer.tags, customer.orders_count, customer.total_spent, customer.b2b?
Cart
cart.item_count, cart.total_price, cart.items
Product & collection
product.tags, product.vendor, product.metafields, collection.handle
Storefront
request.path, request.page_type, localization.country.iso_code, localization.language.iso_code

Starter templates
If you'd rather start from something working than an empty editor, the same panel includes ready-made templates you can drop in and adjust, including a logged-in customer check, a customer-tag check, a cart quantity or cart total minimum, a product-tag check, a visitor-country check, a URL-path check, and a ready-made Shopify B2B customer template that checks customer.b2b? directly.

Steps to manage
Open the lock you want to protect and click the Unlock rules tab.
Add an access rule and set the condition type to Custom liquid.
Write your snippet directly in the editor, or open Variables and templates to copy a variable or start from one of the ready-made templates.
Make sure your snippet's final output is exactly
truefor visitors who should pass and exactlyfalsefor everyone else. Do not add explanatory text, HTML, or other output around the value. The editor flags basic syntax problems, but you still need to confirm the logic matches what you intend.Optionally set a per-rule Redirect URL, used only if this specific rule denies the visitor.
Save the lock.
Fail-open behavior
If a Custom liquid snippet is missing, broken, or fails to render a clear true/false result, the app fails open — it grants access instead of blocking the visitor. This is deliberate, but it also means a broken snippet doesn't fail safe: a merchant who assumes "no result means still locked" would be wrong. Always confirm your snippet actually renders and test it before relying on it to protect anything sensitive.
Example: Allow signed-in customers with a VIP tag
Suppose a private page should only be available to signed-in customers whose account has the vip tag.
Select the VIP collection preview page as the content to protect.

Add Custom liquid and replace the starter snippet with:
The editor confirms Liquid syntax is valid underneath as you type.

Leave the rule's Redirect URL empty.
Set the Access denied message to:
This page is available to VIP customers only.

Click Save.
Result on the storefront
The snippet outputs exactly true for a signed-in customer with the vip tag, so the page opens normally. It outputs exactly false for guests and customers without that tag, so they see the message above. Do not add text before or after true or false in the snippet output.

Related docs
Last updated
Was this helpful?