Locksmith
Install LocksmithContact us
  • Quick Start
  • 💡Basics
    • A Locksmith Overview
    • Creating locks
    • Creating keys
    • Compatibility with other apps and Shopify features
    • Removing Locksmith
  • 🔆Tutorials
    • Approving customer registrations
    • Creating restricted wholesale products
    • Hiding product prices and/or the add to cart button
    • Selling digital content on Shopify
    • More tutorials...
      • Setting up multiple price tiers
      • Customizing messages
      • Customizing the customer login page
      • Customizing the registration form
      • Customizing the passcode form
      • Customizing Locksmith’s "Access denied content" messages, and redirecting customers
      • Customizing the email list signup form
      • Showing multiple prompts on the same page
      • Showing content only to specific Markets
      • Input lists
      • Protecting against bots
      • Earn recurring revenue on your exclusive content using ReCharge
      • Use Locksmith and PayWhirl together to grant access based on subscriptions
      • Liquid locking basics
      • Restricting checkout from the cart
      • Confirmation key condition
      • Restricting customers to a specific collection
      • Passcode-specific redirects
      • Grow your subscriber lists with Klaviyo
      • Use Klaviyo as an access control list
      • Use Mailchimp to collect customer emails
      • Hiding out-of-stock products
      • How to use a private browsing session
      • Granting access to variants by visitor input
      • Offering different variants by postal code
      • Locking products by tag
      • Locking multiple pages at once
      • Making a product accessible exclusively from the direct product link
      • Creating private team areas
      • Importing customers in bulk
      • Disabling Locksmith for certain theme files
      • Adding translations to your Locksmith messages
      • Redirecting using Locksmith
      • Locking variants
        • Limiting the scope of variant locks using the product tag key condition
        • Handling JavaScript DOM errors caused by variant locks
      • Locking the customer registration form
      • Locking the search results page in your store
      • How to clear cache for a single website
      • Disabling Locksmith for certain theme files
      • 🛠️Manual mode
      • Grant access for a limited time when using passcodes or secret links
      • Testing Locksmith on unpublished themes
      • Locking blog posts
      • How to access your browser's dev tools
      • Restricting the cart for mixed products and combinations of products
      • Locking products by vendor
      • How do I hide my Shopify store's header and footer
      • Hiding navigation links for locked resources
      • Hiding products from product-grids
      • Restricting a product so that it can only be purchased by new customers
      • Automatically managing the seo.hidden metafield using Locksmith
      • Locking the home page
      • Setting up checkout validation with Locksmith
      • How to hide theme sections, blocks, and snippets
  • 🔑Keys: Access methods in Locksmith
    • About key conditions
    • Customer account keys
    • Passcode keys
    • Secret link keys
    • Visitor location keys
    • More about keys...
      • Inverting conditions in Locksmith
      • Combining key conditions
      • "Has purchased..." key
      • Using the "Force open other locks" setting
      • Liquid key basics
      • Manual mode
      • Excluding content from locks
      • IP address keys
      • Newsletter keys
      • Limiting the scope of variant locks using the product tag key condition
  • 🌻FAQs
    • Why aren't my locks working?
    • FAQ: I see blank spaces in my collections and/or searches when locking
    • Can Locksmith hide content from my in-store search?
    • Locksmith is not working with my page builder app
    • What should I do if my site is loading slowly?
    • I'm the administrator of my site and I cannot access pages because of Locksmith locks.
    • More FAQs...
      • I'm having trouble using Locksmith with a site speed optimization app.
      • The app isn't loading. What do I do?
      • Can Locksmith protect shipping methods, billing methods, or coupon codes?
      • I switched themes, and Locksmith isn't working
      • Why isn't my passcode, secret link, newsletter, or location key working?
      • Can Locksmith lock Shopify's public JSON API for my online store?
      • Why are my customers seeing a reCAPTCHA when logging in?
      • My passcode or newsletter prompt is not updating on my store when I change it.
      • My featured collections on my home page only show one product.
      • My infinite scrolling doesn't show all of my products.
      • My customers have to enter their e-mail address into the Mailchimp key every time they visit.
      • How do I know which customers have used a certain key?
      • Why is Locksmith adding information to my orders?
      • Locksmith isn't installing correctly!
      • Locksmith is not uninstalling correctly!
      • How does Locksmith affect search engines and SEO?
      • How do I change where customers are redirected to after registration on Shopify
      • The thing I want to lock isn't showing up in the Locksmith search
      • I am getting an "already taken" error when trying to create a metafield definition for seo.hidden
      • How do I add a hero banner image to Locksmith's access messages
  • 📒Policies
    • Usage agreement
    • Locksmith's pricing policy: Pay what feels good
    • Privacy policy
    • Data policy
    • Contact us
  • 🔦Developer Tools
    • Locksmith Admin API
    • Locksmith Storefront API
    • Locksmith variables
    • Unsupported functionality
    • Requests from Locksmith
  • More developer docs...
    • Using the Admin API with Locks
  • App Integrations
    • Easy Appointment Booking
Powered by GitBook
On this page
  • Limitations:
  • Part One: Creating the lock
  • Part two: Theme changes
  • Other considerations:
  • Clearing the cart when a customer signs out:
  • A note about Abandoned Cart emails

Was this helpful?

Export as PDF
  1. Tutorials
  2. More tutorials...

Restricting checkout from the cart

How to use the Locksmith app to add checkout restrictions on your Shopify Online Store

PreviousLiquid locking basicsNextConfirmation key condition

Last updated 2 months ago

Was this helpful?

Locksmith allows you to restrict checkout by using a lock on the cart page in your store. This is a good choice for merchants who want to allow customers to view all content in their store and browse fully, only adding in restrictions on the last page before checkout. Or, to simply add extra restrictions for checking out, on top of other locks in the store.

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’s standard locking methods. This means that checkout links leading directly to checkout—such as ‘Buy Now’ buttons, upsell links, permalinks, or abandoned cart links—cannot be restricted using this approach. However, you can enforce a single checkout restriction using Locksmith’s checkout validation feature. Learn more here: Setting up checkout validation with Locksmith

Moving on, this is the checkout page without any locks in effect:

You can lock the entire cart page if preferred. This will work just like any other Locksmith lock. However, it is also possible to take it further and lock only the "Check out" button. Once Locksmith is set up, the result will be something like one of these screenshots (depending on your settings):

------

Part One: Creating the lock

Use the following steps

1. Open up the Locksmith app and search and for "cart" and click on it, or select it after clicking into the search bar when it comes up in the search dropdown:

2. On the next page, under "Keys", you'll add in your conditions. Here are some of the more common conditions used...

To impose a minimum purchase amount:

To make sure only customers that are signed in and have approved accounts can proceed:

Customer must enter a passcode to checkout:

3. If you just want to lock the entire cart page, click "Save" to finish. If you want to lock only the "Checkout" button, make sure "enable manual locking" is checked under Advanced Settings before saving:

Done with part one!

If you need help with setting up more complicated checkout conditions, Locksmith may be able to help. Just get in touch with us :)

Part two: Theme changes

Some modifications to your shop's theme will need to be done to protect just the checkout button.

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 adding the code for you for you, no problem, so if you're interested, get ahold of us.

Rather do it yourself? Keep reading...

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 the following to the very top of the file:{% capture var %}{% render 'locksmith-variables', variable: 'access_granted', scope: 'subject', subject: cart %}{% endcapture %}{% if var == 'true' %}{% assign locksmith_access_granted = true %}{% else %}{% assign locksmith_access_granted = false %}{% endif %}

  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! :)

Other considerations:

Clearing the cart when a customer signs out:

Note: The script used here isn't an officially supported Locksmith feature. The following is an example of a script that's commonly used to clear a customer's cart when they log out.

Some merchants set up their cart restrictions so that they only apply to certain signed-in customers and the exclusive products they have access to. In this case, it might be possible for customers to sign out to bypass these conditions once restricted products have been added to the cart. If that applies to you, consider ensuring that all products are removed from the cart when a customer signs out.

You can achieve this by adding the following JavaScript to your layout/theme.liquid file, just before the closing 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.

If this script doesn't work in your theme, your theme may not include jQuery libraries. To include those libraries, the following script can be added to an empty line right before the cart clearing script mentioned above.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

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 will not work 100% of the time if you're sending abandoned cart emails, so keep that in mind when you're setting this up. :)

New to manual locking? .

🔆
Check out our general introduction