Shopify themes, liquid, logos, and UX
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.
TyW | Online Community Manager @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
theme.js
or theme.js.liquid
.theme.min.js
.$(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; } }); });
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.<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>
/pages/terms-and-conditions
with the URL of your terms and conditions page.If you use Debut version 17.3.0 or higher, you will need to add JQuery to your theme.liquid file in the Layout directory.
</head>
.</head>
, paste the following code:<link rel="preload" href="https://code.jquery.com/jquery-2.2.4.min.js" as="script">
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
If you use Boundless, you will also need to add the checkbox code to your theme.liquid
file in the Layout directory.
theme.liquid
file, find this line of code:<button type="submit" class="btn btn--full cart__checkout" name="checkout">
<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>
/pages/terms-and-conditions
with the URL of your terms and conditions page.If you use Brooklyn, you will need to add the checkbox code to your ajax-cart-template.liquid
file in the Snippets directory.
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>
<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>
/pages/terms-and-conditions
with the URL of your terms and conditions page.theme.js.liquid
. Find this line of code:theme.checkoutIndicator();Replace it with:
// theme.checkoutIndicator();
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.
cart-template.liquid
.{% if additional_checkout_buttons %} <div>{{ content_for_additional_checkout_buttons }}</div> {% endif %}
{% 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:{% comment %} {% if additional_checkout_buttons %} <div>{{ content_for_additional_checkout_buttons }}</div> {% endif %} {% endcomment %}
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.
theme.liquid
.<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:<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
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:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
TyW | Online Community Manager @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
theme.liquid
.</body>
tag near the bottom of the file.</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>
cart.liquid
.<button type="submit" name="checkout" class="btn">{{ 'cart.general.checkout' | t }}</button>
<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>
/pages/terms-and-conditions
with the URL of your terms and conditions page.If you use Boundless, you will also need to add the checkbox code to your theme.liquid
file in the Layout directory.
theme.liquid
file, find this line of code:<button type="submit" class="btn btn--full cart__checkout" name="checkout">
<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.If you use Brooklyn, you will need to add the checkbox code to your ajax-cart-template.liquid file in the Snippets directory.
ajax-cart-template.liquid
file, find this line of code:<button type="submit" class="btn--secondary btn--full cart__checkout" name="checkout">
<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>
/pages/terms-and-conditions
with the URL of your terms and conditions page.theme.js.liquid
. Find this line of code:theme.checkoutIndicator();Replace it with:
// theme.checkoutIndicator();
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.
cart.liquid
.{% if additional_checkout_buttons %} <div>{{ content_for_additional_checkout_buttons }}</div> {% endif %}
{% 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:{% comment %} {% if additional_checkout_buttons %} <div>{{ content_for_additional_checkout_buttons }}</div> {% endif %} {% endcomment %}
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.
theme.liquid
.<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:<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>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:<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
TyW | Online Community Manager @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi,
I am using Debut theme and I could not get it working with the gived guidelines. Anything specific I should do when using Debut theme?
The button now shows on my site, but it can be bypassed by either not simply marking the box or clicking buy it now button.
I have the same issue when using Debut theme. Everything appears to look fine, but the logic is faulty.
If a customer does not select "I Agree" they can still click checkout and be directed straight to checkout with no pop up.
A solution to this would be much appreciated!
Good morning,
It seems as if the line was missing the required="required" in the line for the cart.liquid. It's working for me now. Try this.
Original:
<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>
Updated with required added ----- USE THIS BELOW:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" required="required" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="Replace with your link to terms and conditions here">terms and conditions</a>.
</label>
</p>
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!
Can you paste the 2 sections here?
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!
Thank you for the great tutorials but the required is not working for me. Also, I don't have that JS line in my theme, should I add that manually?
Hi Dclopez, I tried this but it still let's me checkout with having to click the button, is yours still allowing you to have to click the checkbox?
Hello! This worked for me, but how do I add a pop-up to remind the customers to tick the checkbox before clicking checkout? When they don't click the checkbox, the page just loads and does not proceed to checkout.
@dclopez wrote:Good morning,
It seems as if the line was missing the required="required" in the line for the cart.liquid. It's working for me now. Try this.
Original:
<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>
Updated with required added ----- USE THIS BELOW:
<p style="float: none; text-align: right; clear: both; margin: 10px 0;">
<input style="float:none; vertical-align: middle;" type="checkbox" id="agree" required="required" />
<label style="display:inline; float:none" for="agree">
I agree with the <a href="Replace with your link to terms and conditions here">terms and conditions</a>.
</label>
</p>
Thanks for this post, it's very helpful.
How do I make the checkbox optional and how do I get that data on the product order?
I need to know if the customer checked or did not check the checkbox.
Hello - not sure if you are asking me or@gab33 ? This is not my original post.
I would ask @gab33
Wish I could assist but I don't know the answers to your questions. I am not a developer or a guru. I used the code for my brooklyn theme and it worked.
https://goddessswag.com if you want to see my checkout set up.
@TyW thank you for the posts. I have the same question as developertmc below, would you be able to point us in the right direction please?
@developertmc did you work out how to make the checkbox optional and collect the information of whether they tick the checkbox? We are trying to do the same here...
@developertmc wrote:Thanks for this post, it's very helpful.
How do I make the checkbox optional and how do I get that data on the product order?
I need to know if the customer checked or did not check the checkbox.
Any updates as to how to make this checkbox required? I can bypass it by clicking the checkout button.
Hi,
I'm running Debut theme and this seems to not work. Any way around it that you can find? It's still not making it "Required".
Thank you!
how do i preselect the checkox
Hello! I added the required part to the line of code, but mine is still not working. Have you had any issues with this by chance?
Thanks!
rhiandddept.com
Thanks for the code snippets to achieve the required functionality.
In the Dawn theme, please look for the other matching files as mentioned below:
Also, use <a href="/pages/terms-and-conditions" target="_blank"> INSTEAD OF just <a href="/pages/terms-and-conditions"> so that the original cart page is intact. And, the terms & conditions page opens up in a new window, which could be closed after reading and still the cart window is available for the customer to checkout.
All this worked for me in Debut theme. I believe this information would help!
This didnt work for me. Is there another way to make the check box required? Im using the Dawn theme.
I'd also like to position the checkbox and statement to the left and elongateits margins. how can I achieve this?
I enden up using the app "Terms and Conditions Checkbox". Not a perfect solution, but for now it works.
I made the change but it still lets customers go through without clicking the checkbox.
Hi , Would you mind letting me know how you find the link of URL of your terms and conditions page? Thanks in advance
Debe ser porque estas utilizando theme.liquid en ves de theme.js
Yo tuve el mismo problema pero si copias el código html correctamente todo funciona bien, revisa lo que te digo, no utilices la sección theme.liquid
Sorry - i was asking a question of the community, not providing an answer!
Which format/coding section did you use for your debut theme? I also have debut and am not sure which one to use.
had the same, but this fixed it for me and might help some people so leaving it here: https://community.shopify.com/c/technical-q-a/terms-and-conditions-checkbox-not-working-refresh-them...
Just want to say to all, if you are from Germany.
This tutorial is useless, because the ckeckbox appears on cart, but not on the last step of checkout.
I spend some hours to realize that I'am working on cart-template and this file is not the checkout page, on which I test it and refresh it like idiot.
Ckeckout page appears if the buyer clicks "buy now" button and goes thru many pages with forms.
And according to german laws this checkbox muss be near of the "complete order" button on the last step.
Hi Kalobyte,
as i am intergrating the buy button in our wordpress page, could you tell me how you solved to implement this at the last page (complete order?)
Thanks a lot and greetings from germany
Thanks for the tutorial. I'm using Debut and the button now shows on my site, but it can be bypassed by either not simply marking the box or clicking "buy now" button. Moreover, now when you click "Buy now" button, the button fades away before taking you to checkout, resulting in a longer waiting time before reaching the checkout page.
Any solution?
P.S I'm using the latest debut version, which is probably updated compared to the one of this tutorial.
Hi I am using Modular theme and in second step:
I dot have in this section <button> or an <input> I have just this codes:
Can someone help with this what to do?
thank you so much 🙂
User | RANK |
---|---|
197 | |
156 | |
79 | |
69 | |
66 |
Explore the 30-30-30 rule, a dynamic social media strategy for new businesses. Learn how t...
By Trevor Sep 20, 2023Discover how to leverage the often overlooked footer of your ecommerce site to gain custom...
By Skye Sep 15, 2023In this blog, we’ll be shining a light on Shopify Partners, Experts, and Affiliates. Who a...
By Imogen Sep 13, 2023