Restricting the cart for mixed products and combinations of products

Locksmith can be used to restrict checkout from the cart page by creating a lock for the cart. This lock can be used to hide the whole cart page, or to only lock the checkout buttons on the cart page. Locksmith has a few cart specific key conditions that can be used to check specific attributes of a customers' cart. This guide will primarily focus on the use of the “has a certain product in their cart” key condition.

Preventing access to the checkout from the cart

Our guide on setting up a cart lock is linked below. That guide covers both locking the whole cart page and locking the checkout button.

Restricting checkout from the cart

Locking the checkout button can be a better option here. This will allow customers to still be able to edit the products in the cart, even when the checkout button is locked.

Managing cart access based on products in the cart

There are three general ways of restricting access to the checkout via your Shopify cart based on mixed products or combinations of products. Keep in mind, this isn’t an exhaustive list.

Preventing checkout with mixed products from two different groups of products. Eg. Wholesale and Retail

The "Look for products matching…" field on the "has a certain product in their cart" key condition can be used to check for a product title, or product tags. For example, "tag:wholesale will check for any products with the "wholesale" tag.

You will need to create three separate keys for your cart lock. Our guide on adding keys is here for reference: Creating keys

1. You’ll need a key that grants access if a customer does have products tagged with the "wholesale" products tag (for example) in the cart, but only if the customer doesn't have any products tagged with "retail" in the cart.

  • Create a key and then select the "has a certain product in their cart" key condition and add “tag:wholesale” to the "Look for products matching…" field on the condition.

  • Then combine a second "has a certain product in their cart" key condition with the first, add “tag:retail” to the "Look for products matching…" field on the condition, and then invert the condition. Combining Key Conditions Inverting conditions in Locksmith You should have a key that looks like the following image.

    Image 1. Key with key condition combination to allow access for wholesale products with no retail.

2. The second key will use a set of conditions that are the inverse of the fist key, to grant access to customers who don't have any products tagged with "wholesale" in the cart but do have products tagged with "Retail" in the cart.

  • Create a new key by clicking the “+Add key” button and then select the "has a certain product in their cart" key condition and add “tag:retail” to the "Look for products matching…" field on this condition.

  • Then combine a second "has a certain product in their cart" key condition with the first, add “tag:wholesale” to the "Look for products matching…" field on the condition, and then invert this condition. You should have a key that looks like the following image.

    Image 2. Key with key condition combination to allow access for retail products with no wholesale.

3. This third key is only required, if you have another set of products, other than wholesale and retail, that can be purchased with anything product.

The third key can be used to grant access for when there are no products with the "wholesale" or "retail" tags in the cart. This will require the combination of two inverted "has a certain product in their cart" key conditions, one of each product tag.

You should have a key that looks like the following image.

Image 3. Key with key condition combination to allow access when no wholesale or retail products are in the cart.

Limitations:

  • The method locks down the cart page only. The cart page is always found at the '.../cart' link in your store (e.g. www.example-store.com/cart). Using other types of carts (slider, dropdown, dynamic/ajax, etc.) or adding "Buy Now" links to your store (which point the customer directly to checkout without going through the cart page) will not work with this method.

  • Locking the checkout area itself is not possible using Locksmith. So any check out links that lead straight to checkout including "Buy Now" button, upsell links, or abandoned cart links can't be used with this method. Please see Setting up checkout validation with Locksmith

Something else not covered here?

Let us know by emailing us at [email protected]

Last updated

Was this helpful?