Add a "Terms and conditions" checkbox
This article hasn't been revised for version 3.x
Adding a "terms and conditions" checkbox to your cart page Split theme:
- From your Shopify admin, go to Online Store > Themes.click Actions > Edit code.
- In the Assets directory, click theme_min.js file (or js_main.min.js file if you are using an older theme version).
- At the bottom of the file, paste the following code:
- Click Save.
- In the Snippets directory, click cart_form.liquid find the HTML code for your cart total:
- Within the code you just pasted, replace
/pages/terms-and-conditions
with the URL of your terms and conditions page.Note: You will need to create a terms and conditions page if it doesn't already exist.
- Click Save.
$(document).ready(function() { $('#section-cart').on('click', '[name="checkout"]', function() { if ($('#section-cart #agree').is(':checked')) { $(this).submit(); } else { alert("You must agree with the terms and conditions of sales to check out."); return false; } }); $('#site-cart').on('click', '[name="checkout"]', function() { if ($('#site-cart #agree').is(':checked')) { $(this).submit(); } else { alert("Please first agree with the terms and conditions of sales to check out."); return false; } }); });
<p id="CartTotal">{{ 'cart.total' | t }} <span>{{ cart.total_price | money }}</span></p> <small>{{ 'cart.shipping_at_checkout' | t }}</small>
On a new line below the cart total, paste the following code:
<p style="float: none; text-align: left; 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>