Cart - Add an 'Agree to terms and conditions' checkbox

TyW
Community Manager
Community Manager
435 50 1182

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.

 

tc-01.jpg


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

Replies 156 (156)
JP30
Tourist
14 0 1
Thanks Alibabyph

But unfortunately it does not work...
Kerchie
Tourist
3 0 1

I got it to work. Now I need to know how to make the error message inline instead of a popup. Like if they don't click the box, I want the error message to point to the box.

bisarone
Visitor
1 0 0

I'm looking for this as well, all i get is the native browser pop-up. But i want the error message appear in red underneath the checkbox, so it's in context.

PJeatery
Visitor
2 0 0

This didnt work for me

CS69
Visitor
2 0 0

Thank you!

I'm on theme Venture, it works but the text appears in uppercase...

How can I have it in a normal font, with a capital letter only when I put a capital letter?

StatementCph
Tourist
22 0 0

I am currently using Parallax as theme.

Apparently with my theme it's very difficult to add this option on my checkout page. I tried to code it accordingly to the forum suggestions, but it didn't work. Can someone help me with it?

 

Wyrock
Visitor
2 0 0

For me, I am in the Debut theme, and I had to insert the line of code for the checkbox below the submit to cart button. It was very finicky! Good luck!

Happycreatures
Visitor
1 0 0

Hello TyW,

Thanks for sharing such magical things to all of us.

I actually am not an expert on editing code, and please do me a favor.

I am using the theme Narrative with a drawer cart, and follow the instruction of the sectioned theme, yet the checkbox and sentence do not appear.

What information should I provide to let you figure it out?

Thank again.

alibabyph
Tourist
8 0 3

Hello. I'm not an expert but reading all of the replies in here, I was able to do it on my Narrative theme.

I followed the steps posted here but I did some modifications to make it work on my theme.

I repeat, I"M NOT AN EXPERT I JUST DID THIS ON MY OWN haha! It may or may not work for you.

So here it is...

 

First, I put these codes on my custom.js and NOT in the theme.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;
      }
    });
  });

 

 

Second, my cart is a drawer, so I also put these codes on my cart-drawer.liquid. Not just on my cart-template.liquid.

NOTE: THESE CODES ARE MODIFIED. NOT THE ONE ORIGINALLY POSTED AT THE TUTORIAL.

I added attribute to the <a> tag. So my T&C will open as a POPUP.

If you want to open it in a NEW TAB instead, just change the target="popup" to target="blank" and remove the following words up to false;.

I also added a style property inside the <a> tag with the color that I want for the link. You can remove it or change it whatever you like.

 

<p style="text-align: center"; 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="/pages/terms-conditions" target="popup" onclick="window.open('http://alibaby.ph/pages/terms-conditions','popup','width=600,height=600'); return false;" style="color: #ff8da0">terms and conditions</a>.
</label>
</p>

 

 

These are the results:

popup.png

 

cart.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

BONUS:

I tried adding the same codes on my customers/register.liquid and voila! IT WORKED! LOL.

I added some style to make it centered.

This is how my liquid file looked like.

 

<!-- /templates/customers/register.liquid -->
<div class="page-width customers-register">
  <div class="grid">
    <div class="grid__item medium-up--four-fifths medium-up--push-one-tenth">
      <div class="customers-register__container">
        <h1 class="customer-form__title h2" style="text-align: center">{{ 'customer.register.title' | t }}</h1>

        {% form 'create_customer' %}
        {{ form.errors | default_errors }}

        <div class="grid">
          <div class="grid__item medium-up--one-half">
            <label for="FirstName" class="label--hidden">{{ 'customer.register.first_name' | t }}</label>
            <input type="text" name="customer[first_name]" id="FirstName" placeholder="{{ 'customer.register.first_name' | t }}" {% if form.first_name %}value="{{ form.first_name }}"{% endif %} autocapitalize="words" autofocus>
          </div>

          <div class="grid__item medium-up--one-half">
            <label for="LastName" class="label--hidden">{{ 'customer.register.last_name' | t }}</label>
            <input type="text" name="customer[last_name]" id="LastName" placeholder="{{ 'customer.register.last_name' | t }}" {% if form.last_name %}value="{{ form.last_name }}"{% endif %} autocapitalize="words">
          </div>
        </div>

        <label for="Email" class="label--hidden">{{ 'customer.register.email' | t }}</label>
        <input type="email" name="customer[email]" id="Email" class="{% if form.errors contains 'email' %} input--error{% endif %}" placeholder="{{ 'customer.register.email' | t }}" {% if form.email %} value="{{ form.email }}"{% endif %} autocorrect="off" autocapitalize="off">

        <label for="CreatePassword" class="label--hidden">{{ 'customer.register.password' | t }}</label>
        <input type="password" name="customer[password]" id="CreatePassword" class="{% if form.errors contains 'password' %} input--error{% endif %}" placeholder="{{ 'customer.register.password' | t }}">

		<p style="text-align: center"; 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="/pages/terms-conditions" target="popup" onclick="window.open('http://alibaby.ph/pages/terms-conditions','popup','width=600,height=600'); return false;" style="color: #ff8da0">terms and conditions</a>.
			</label>
		</p>    
        
        <p style="text-align: center">
          <input type="submit" value="{{ 'customer.register.submit' | t }}" class="btn">
          <a href="{{ shop.url }}" class="btn btn--clear">{{ 'customer.register.cancel' | t }}</a>                                                      
        </p>
      {%endform%}
      </div>
    </div>
  </div>
</div>

 

 

And this is the actual result:

register.png 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

THAT'S ALL! I HOPE THIS COMMENT HELPED YOU ON YOUR NARRATIVE THEME AS WELL! YOU CAN PRIVATE MESSAGE ME IF YOU HAVE QUESTIONS! THANKS!

fab2lats
Visitor
1 0 1

Ok so people are not very good at explaining on how to do this for people who are not familiar with programming. I struggled and finally completed this, although half-way.

Did this on Debut theme, the "Accept to terms and conditions" warning shows up only after "Add to cart" is selected. If i select "Buy now" nothing happens as it bypasses the Cart directly to the Checkout so i had to disable Buy now button. Would appreciate if anyone could offer a solution so that the Terms and conditions checkbox appears in the window where customer must enter billing and shipping information (After clicking "Add to cart" or "Buy now"). I suppose it's called Contact_information / page.contact.liquid.

1. Go to "Online store"-> Select your live theme -> Actions -> Edit code

2. Select Assets folder, find theme.js

3. Go to the very end and paste the 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;
}
});
});

You can translate text "You must agree with the terms and conditions of sales to check out." to whatever language your shop is directly in the code.

4. Click Save, then go Sections->find Cart-template.liquid

5. Look for this code using Ctrl+F and search for cart.general.checkout

<div class="cart__shipping rte">{{ taxes_shipping_checkout }}</div>
<div class="cart__buttons-container">
<div class="cart__submit-controls">
{%- unless section.settings.cart_ajax_enable -%}
<input type="submit" name="update"
class="cart__submit btn btn--secondary"
value="{{ 'cart.general.update' | t }}">
{%- endunless -%}
<input type="submit" name="checkout"
class="cart__submit btn btn--small-wide"
value="{{ 'cart.general.checkout' | t }}">
</div>

6. Directly before the line <input type="submit" name="checkout" paste this code:

<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="/policies/terms-of-service"> terms and conditions</a>.
</label>
</p>

So your final code looks like this:

<div class="cart__shipping rte">{{ taxes_shipping_checkout }}</div>
<div class="cart__buttons-container">
<div class="cart__submit-controls">
{%- unless section.settings.cart_ajax_enable -%}
<input type="submit" name="update"
class="cart__submit btn btn--secondary"
value="{{ 'cart.general.update' | t }}">
{%- endunless -%}
<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="/policies/terms-of-service"> terms and conditions</a>.
</label>
</p>
<input type="submit" name="checkout"
class="cart__submit btn btn--small-wide"
value="{{ 'cart.general.checkout' | t }}">
</div>

7. Click Save, go check your shop if it works.

8. To disable "Buy now" button go to Online store -> Customize

9. At the top left of the website preview (where Home Page is written by default) select "Product pages"

10. In the Sections click Product Pages and disable "Show dynamic checkout button"

bunuzn
Tourist
6 0 1

Hey guys!

I found this app can do the same trick for the cart page, also it seems it can create a pop-up for the Buy Now button. Anybody tested?

https://apps.shopify.com/terms-and-conditions-in-cart

Also found this free app with more reviews, but at my first look it doesn't have the Buy Now block feature. https://apps.shopify.com/tos

LuxPetco
Excursionist
20 0 2

Thank you Alibabyph!!! You absolutely saved me time and money with this code!! It worked beautifully with my Narrative theme. And I absolutely love the extra bit in the create an account section. Perfect. 🙂

EhrenmannAndi
Visitor
1 0 0

Thank you so much @alibabyph !!!!! If you got a donation link or something, please tell me! I'll send you a little gift for saving my life!

Swagdaddy
Visitor
1 0 0

Is it possible to add a second box?  I’ve added one but you’re only required to click the original box.  You can just click the first box and continue on.  I’d like it so both boxes must be checked before proceeding.  Thank you much!!!

Clawevent
Visitor
2 0 1

Hi! 

 

I am using the theme Emerge. I followed these instructions however the check box is still not required! One disparity I noticed was that my cart.liquid under templates does not include any content except 

{% render 'framework--cart', view: 'desktop' %}
{% render 'framework--cart', view: 'mobile' %}

 

I found framework--cart.liquid under snippets. Does this affect the code needed? 

 

Thanks for anyone that can provide some insights!

factorystudiotx
Visitor
1 0 0

Thank you. This was very helpful. I am curious if anyone knows how to hide this checkbox unless a particular item (or tags/collections/product types) is added to cart.

 

For example, I am going to be selling a combination of merchandise and in-store appointments. If a customer orders merch, they will not need this checkbox. If they order something from one of my other 3 collections they will need to accept the terms for service. 

 

Thanks

lovingallmybody
Visitor
1 0 0

What do you do if theme.js or theme.js.liquid isn't an option on your theme? We have Modular and I only see tms.js.

 

Thanks!

adam_smb
Shopify Partner
1 0 0

@TyW - Thank You!!
Question, is there a way to then add a comment into the Cart Comments when they tick the box? 
We want to be able to store 'Authority To Leave' in the Comment box so that is then linked into the order in our IMS.

 

TIA

savich
Visitor
1 0 0

Thanks a lot for a great tutorial! Worked perfectly for me.

JPCancino
Excursionist
27 0 9

Hello @TyW 

Many thanks for your help. I have a doubt with your solution. It would be very nice if you can help me.

Why did you comment the line :

In the Assets directory, click theme.js.liquid. Find this line of code:

theme.checkoutIndicator();

Replace it with:

// theme.checkoutIndicator();

I'm using Debutify Theme and I did comment that line but the slideshow disapear after do it. I don't know what is wrong with that or my template.

christianploege
Visitor
1 0 1

hi there

im chris from denmark

i use narrative theme for mig shop. i tried to paste them codes in the right places. but no i agree button comes up.

what to do then

best regards chris

RomyL
Visitor
1 0 0

Hi Ty,

thank oyu so much - this is soooo helpful for no-coders like me 🙂 thanks a million! 

may I add one non-coder question? How do I manage to translate the now showing texts? I have been foolishly trying to add the "agree" id to the language json files, but (of course) I failed 🙂

Could you give me a hint?

 

Thank you so much and best
Romy

Crystalmarlyn
Visitor
2 0 0

Hi I did this for the Brooklyn theme and some how I deleted something where now I on my site you can't even check out. I followed your directions but seemed to have deleted the wrong thing PLEASE HELP!  

 

This is what it is currently on the Assets- Theme.js.liquid currently;

 

// theme.checkoutIndicator();
// Add a loading indicator on the cart checkout button (/cart and drawer)
theme.cache.$body.on('click', '.cart__checkout', function() {
$(this).addClass('btn--loading');
});

NailMeNow
Visitor
1 0 0

This was extremely helpful thank you. 

I have followed the exact steps and successfully have my checkbox. 

Is it also possible to add the refund policy to this statement so it would instead say I agree with the Terms and conditions and Refund policy

Many thanks 

shopcami
Explorer
49 0 18

Hello @TyW 

Thank you for this! Is there a way to make the checkbox bigger?

Ty3shia
Visitor
1 0 0

Super easy and straightforward 

SiamBlades
Tourist
8 0 1

Are we able to view the Terms & Conditions Checkbox after the cart page? Is there an overview order page that shows the customer selected the Terms & Condition box?  I am looking for evidence the customer selected this box on the order page or elsewhere to provide in the event of chargebacks.

CallmeAJ
Tourist
3 0 2

I added the code you have posted on your comment, the box is there and able to be checked... I am not getting the prompt when the box is left uncheck and I then click check out. 

Pauline_Millwar
Tourist
10 0 9

Hi,

Please can you advise what needs to be done to the new Dawn theme for this to work ie add the checkbox and restrict the customer from continuing unless they have "checked" the box. Many thanks 🙂

MikeCronin
Excursionist
30 0 3

Hi there. Followed all the steps to do so but hit an issue with the dialog warning not popping up if the checkbox isn't checked-off. 

Any recommendations on how to solve?

skmeico
Tourist
18 0 1

I added the codes to my my Dawn Theme and able to see the terms and conditions box, but it is not alligned properly, how to allign it? Also the Check out Box became more height

skmeico_0-1636710018419.png

Please help me

 

TAGSAngel
Trailblazer
147 1 85

this tutorial was extremely helpful.  My only question is how do we get the  "Agreed to terms & conditions" to show up on the order confirmation and our notification of order.  unfortunately sometimes we need to provide proof to them that they agreed .

Michelle_Lee
Shopify Partner
1 0 0

I also want to know the same: 
1. How can we show proof/confirmation that the terms are checked? 

2. Can we ensure that customer cannot proceed to checkout until the checkbox is ticked? 

cvolden
Visitor
2 0 0

@TyW Hello! I have inserted the two code snippets for the sectioned theme, the checkbox is there, however you can still go to the checkout without checking the box. I tried the js version script edit but could not find it within theme.liquid. This is on the Prestige theme, do you happen to have further insight on this solution for this particular theme? Thank you!   

Dan444
Visitor
2 0 0

I am using Crave theme. So that I am following steps for sectioned themes. However, I can't find  theme.js or theme.js.liquid under the my code. I am able to input the check box but not function. Please help.