A tutorial explains how to add a mandatory ‘Agree to terms and conditions’ checkbox to Shopify cart pages using custom code. The implementation differs between sectioned themes (post-2016) and non-sectioned themes, requiring edits to theme.js/theme.liquid and cart template files with jQuery code.
Key Implementation Issues:
The checkbox can only be added to the cart page, not the actual checkout page (unless using Shopify Plus at $2,000+/month)
Many users report the checkbox appears but isn’t actually required—customers can bypass it
Solutions include adding required="required" attribute or creating a separate custom.js file
Additional checkout buttons (Apple Pay, Google Pay) bypass the validation entirely
Theme-Specific Challenges:
Dawn, Debut, Narrative, Prestige, and Brooklyn themes require different approaches
Some themes need code in custom.js instead of theme.js due to load order issues
jQuery version must be 1.7 or higher for the code to function
Legal Compliance Concerns:
Multiple users note this workaround is insufficient for EU/German regulations requiring checkboxes at final checkout
The limitation frustrates merchants needing proper consent collection for legal compliance
Current Solutions:
A free app (RA Terms and Conditions Checkbox) now exists as an alternative to manual coding
Various code modifications shared for handling cart drawers, multiple checkboxes, and styling adjustments
Summarized with AI on November 2.
AI used: claude-sonnet-4-5-20250929.
This is an advanced tutorial and is not supported by Shopify. Knowledge of HTML, CSS, JavaScript, and Liquid is required. Consider hiring a Shopify Expert if you aren’t comfortable doing the steps in the tutorial.
You can add an I agree with the terms and conditions checkbox to your cart page that customers must check before continuing to the checkout. If a customer doesn’t check the checkbox before clicking the checkout button, an alert pop up will prevent them from continuing.
Tip: It’s not possible to add the checkbox to the checkout pages. It can be added only to the cart page that exists at http://www.your-shop-URL.com/cart.
The steps for this tutorial differ depending on whether you are using a sectioned or a non-sectioned theme. A sectioned theme is a newer theme that lets you drag and drop to arrange the layout of your store’s pages.
To figure out whether your theme supports sections, go to the theme’s Edit code page. If there are files in the Sections directory, you are using a sectioned theme. Non-sectioned themes were released before October 2016, and do not have files in the Sections directory.
If you are using a sectioned theme, then click the Sectioned themes button and follow the instructions. If you are using an older, non-sectioned theme, then click the Non-sectioned themes button and follow the instructions.
Adding a checkbox to your cart page1. From your Shopify admin, go to Online Store > Themes.
Find the theme you want to edit, and then click Actions > Edit code.
In the Assets directory, click theme.js or theme.js.liquid. Note: For the Narrative theme, click theme.min.js.
At the bottom of the file, paste the following code:
$(document).ready(function() {
$('body').on('click', '[name="checkout"], [name="goto_pp"], [name="goto_gc"]', function() {
if ($('#agree').is(':checked')) {
$(this).submit();
}
else {
alert("You must agree with the terms and conditions of sales to check out.");
return false;
}
});
});
Click Save.
In the Sections directory, click cart-template.liquid. If there is no cart-template.liquid file in the Sections directory, then click cart-template.liquid or cart.liquid in the Templates directory.
Find the HTML code for your checkout button. Look for a <button> or an <input> element with the name attribute set to checkout. The code might look something like this:
<button type="submit" name="checkout" class="btn">{{ 'cart.general.checkout' | t }}</button>
On a new line above the checkout button, paste the following code:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="/pages/terms-and-conditions">terms and conditions</a>.
</label>
</p>
Within the code you just pasted, replace /pages/terms-and-conditions with the URL of your terms and conditions page.
On a new line before the above line of code, paste the following code:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="/pages/terms-and-conditions">terms and conditions</a>.
</label>
</p>
Within the code you just pasted, replace /pages/terms-and-conditions with the URL of your terms and conditions page.
Click Save.
Brooklyn
If you use Brooklyn, you will need to add the checkbox code to your ajax-cart-template.liquid file in the Snippets directory.
In your ajax-cart-template.liquid file, find this line of code:
<button type="submit" name="update" class="btn--secondary update-cart">{{ 'cart.general.update' | t }}</button>
On a new line before the above line of code, paste the following code:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="/pages/terms-and-conditions">terms and conditions</a>.
</label>
</p>
Within the code you just pasted, replace /pages/terms-and-conditions with the URL of your terms and conditions page.
Click Save.
The next step for Brooklyn is to comment out a line of code in your theme’s JavaScript file.
In the Assets directory, click theme.js.liquid. Find this line of code:
theme.checkoutIndicator();
Replace it with:
// theme.checkoutIndicator();
Click Save.
Removing the additional checkout buttons from your cart page
If you’ve added checkout buttons other than PayPal to your cart page, then the terms and conditions checkbox won’t work properly. For example, if you have the Pay with Amazon button on your cart page, then your customers will be able to click it and check out without agreeing to your term and conditions.
If you have a payment option that has its own checkout button, other than PayPal, you will have to remove the additional checkout buttons from the cart page. After customers have checked the checkbox you’ve added and reached the checkout, they will still be able to select the additional payment option from the Payment method page.
In the Sections directory, click cart-template.liquid.
Find the following code:
{% if additional_checkout_buttons %}
<div>{{ content_for_additional_checkout_buttons }}</div>
{% endif %}
When you find the code, wrap it in Liquid {% comment %} and {% endcomment %} tags. This will stop the code from being shown on your store, and you can easily add it back if you want to change your new template later. Your code should look like this:
Updating older themes to use a supported version of jQuery
If you are having trouble getting the ‘Agree to terms and conditions’ checkbox to work, then confirm that your theme is using a jQuery version of 1.7 or newer. If your theme is running a version of jQuery that is older than 1.7, then you can edit your theme code to use a supported version instead.
In the Layout directory, click theme.liquid.
Within the <head> element, find a script tag that references your theme’s jQuery source. The src attribute for the script tag contains a URL that includes /jquery/, followed by the version number. The tag looks something like this:
In the script tag above, the jQuery version being used is 1.4.2. This is an older version of jQuery that will need to be updated for the customization to work. If your theme is using a version that is older than 1.7, replace the version number in the URL with 1.7. The result should look like this:
Non-sectioned themes### Adding a checkbox to your cart page in non-sectioned themes1. From your Shopify admin, go to Online Store > Themes.
Find the theme you want to edit, and then click Actions > Edit code.
In the Layout directory, click theme.liquid.
Find the closing </body> tag near the bottom of the file.
Above the closing </body> tag, paste the following code:
<script>
$('body').on('click', '[name="checkout"], [name="goto_pp"], [name="goto_gc"]', function() {
if ($('#agree').is(':checked')) {
$(this).submit();
}
else {
alert("You must agree with the terms and conditions of sales to check out.");
return false;
}
});
</script>
Click Save.
In the Templates directory, click cart.liquid.
Find the HTML code for your checkout button. Look for a or an element with the name attribute set to checkout. The code might look something like this:
<button type="submit" name="checkout" class="btn">{{ 'cart.general.checkout' | t }}</button>
On a new line above the checkout button, paste the following code:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="/pages/terms-and-conditions">terms and conditions</a>.
</label>
</p>
On a new line before the above line of code, paste the following code:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="/pages/terms-and-conditions">terms and conditions</a>.
</label>
</p>
Within the code you just pasted, replace /pages/terms-and-conditions with the URL of your terms and conditions page.
Click Save.
The next step for Brooklyn is to comment out a line of code in your theme’s JavaScript file.
In the Assets directory, click theme.js.liquid. Find this line of code:
theme.checkoutIndicator();
Replace it with:
// theme.checkoutIndicator();
Click Save.
Removing the additional checkout buttons from your cart page
If you’ve added checkout buttons other than PayPal to your cart page, then the terms and conditions checkbox won’t work properly. For example, if you have the Pay with Amazon button on your cart page, then your customers will be able to click it and check out without agreeing to your term and conditions.
If you have a payment option that has its own checkout button, other than PayPal, you will have to remove the additional checkout buttons from the cart page. After customers have checked the checkbox you’ve added and reached the checkout, they will still be able to select the additional payment option from the Payment method page.
In the Templates directory, click cart.liquid.
Find the following code:
{% if additional_checkout_buttons %}
<div>{{ content_for_additional_checkout_buttons }}</div>
{% endif %}
When you find the code, wrap it in Liquid {% comment %} and {% endcomment %} tags. This will stop the code from being shown on your store, but will let you easily put it back if you want to change your new template later. Your code should look like this:
Updating older themes to use a supported version of jQuery
If you are having trouble getting the ‘Agree to terms and conditions’ checkbox to work, then confirm that your theme is using a jQuery version of 1.7 or newer. If your theme is running a version of jQuery that is older than 1.7, then you can edit your theme code to use a supported version instead.
In the Layout directory, click theme.liquid.
Within the <head> element, find a script tag that references your theme’s jQuery source. The src attribute for the script tag contains a URL that includes /jquery/, followed by the version number. The tag looks something like this:
In the script tag above, the jQuery version being used is 1.4.2. This is an older version of jQuery that will need to be updated for the customization to work. If your theme is using a version that is older than 1.7, replace the version number in the URL with 1.7. The result should look like this:
Used the sectioned Theme instructions and everything worked, except for the warning doesn’t pop up. You can still check out without selecting you agree. Any advice on this? I’m using the Block Shop Theme. This is what I found.
Hello Thank you for commenting on the article, it did not work for me also, I did follow your adjustments and was still not able to get the “required” portion to work out. Would you be able to assist me that? That would seriously be awesome thank you!
Hi, the info for the Brooklin theme does not match to the code. Why is it so ? I need a solution to this subject. I can not edit the code due to this problem.
Hi, I followed the tutorial and everything is great, except for one thing. If I use internet explorer to reach the shop, in the shopping cart page the checkout button vanishes and doesn’t work properly. The popup for consent doesn’t come out and you can’t finalize the payment
I am using the Venture theme and I had noticed this and changed it to required but you are still able to bypass the checkbox. Any other solutions to fixing this problem?
The logic makes sense it just doesn’t want to work! So frustrating!