Restricting checkout from the cart

New to manual locking? Check out our general introduction.

There are two setup components for this scenario: some modifications to your shop's theme to protect just the checkout button, and the Locksmith lock and key configuration itself.

Because each theme is a bit different, this feature does require manual coding. If you install a new theme down the road, these changes will need to be re-applied.

The rest of this guide gets a bit technical! We can take care of setup for Locksmith subscribers, so if you're interested, make sure your subscription is in good standing, then email me :)

First up: Theme changes

In this portion, you'll update your shop's theme to protect just the checkout button(s) on your cart, allowing your visitors to manage their cart but not check out until they meet your criteria.

  1. From your Shopify admin area, navigate to "Online Store" -> "Themes". Then, click the three-dots button in the upper-right corner for your theme, and select the "Edit HTML/CSS" option.
  2. Open the "cart.liquid" file (under "Templates"). If you have a newer "sectioned" theme, you may actually need to edit the "cart-template.liquid" file (under "Sections")
  3. Add {% include 'locksmith-variables' %} at the very top of the file.
  4. Find the checkout submit button(s), and wrap this code with {% if locksmith_access_granted %} ... {% endif %} . You can also add an "else" section to show a message to anyone who's been prevented from checking out.Here's a pretty typical example:


<input type="submit" name="checkout" class="btn" value="{{ 'cart.general.checkout' | t }}">

{% if additional_checkout_buttons %}
  {{ content_for_additional_checkout_buttons }}
{% endif %}


{% if locksmith_access_granted %}
  <input type="submit" name="checkout" class="btn" value="{{ 'cart.general.checkout' | t }}">

  {% if additional_checkout_buttons %}
  {{ content_for_additional_checkout_buttons }}
  {% endif %}
{% else %}
  <p>Please add at least $50 to your cart to check out.</p>
{% endif %}

Save the template, and you're done! :)

Next: Locksmith configuration

  1. Open Locksmith, from your store's Apps list.
  2. Click the link beneath the search box for locking your cart, then click the cart option that appears, and click Save.
  3. On the next screen, under Settings, click on Advanced, and then enable manual locking using the checkbox.
  4. Then, use the "Keys" section to determine under what circumstances the visitor should be allowed to check out. Commonly, you'll want to use the "the visitor has at least $x in their cart" option, which will let you determine an order minimum. Make sure to save the key when you're done!

Finally: Check your customer account settings

If your customer account settings are set to "Optional", and only signed-in customers are subject to checkout restrictions, they could bypass those restrictions by signing out when the items are already in the cart.

You can fix that by adding this bit of code to your layout/theme.liquid file, just below the </body> tag:

  $(document).on('click', 'a[href="/account/logout"]', function (e) {
    $.ajax({ method: 'POST', url: '/cart/clear.js' }).always(function () { window.location = '/account/logout'; });

This will clear the cart when the logout button is pressed, preventing that workaround.

A note about Abandoned Cart emails

If you have abandoned cart emails enabled on your shop, either through the built-in Shopify feature or an app, those emails may allow the customer to circumvent checkout restrictions. 

These emails can send the customer directly to the checkout process without touching the cart page. The customer will be able to check out with whatever amount was in the abandoned cart, whether or not it passes your restrictions. 

Your checkout restrictions may not work 100% of the time if you're sending abandoned cart emails, so keep that in mind when you're setting this up. :)

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.