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 isaac@uselocksmith.com. :)

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").
  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:

Before:

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

{% if additional_checkout_buttons %}
  <div>{{ content_for_additional_checkout_buttons }}</div>
{% endif %}

After:

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

  {% if additional_checkout_buttons %}
    <div>{{ content_for_additional_checkout_buttons }}</div>
  {% 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. Log in at uselocksmith.com.
  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:

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

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?