How to add an Agree to terms and conditions checkbox to the cart page in Shopify?

How to add an Agree to terms and conditions checkbox to the cart page in Shopify?

If you want to add a Terms and Conditions checkbox on the cart page, then follow these simple steps:

hexpoundsofttechsolution How to add an Agree to terms and conditions checkbox to the cart page in Shopify?

1. Log in to Shopify admin, go to Online Store > Themes.

2. Select the theme you want to edit, then click Actions > Edit code.

3. In the Assets directory, find the javascript file and open it.

4. Paste the below code at the bottom of the file.

<script>
$(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;
      }
    });
});
</script>

5. Click on Save.

6. In the Templates directory, Open the cart.liquid file, then open cart-template.liquid.

7. Find the HTML code for your checkout button. The code will look like this:

<button type="submit" name="checkout" class="checkbox_btn">{{ 'cart.general.checkout' | t }}</button>

8. Paste the following code, above the checkout button.

<p style="width:100%; text-align: right; display:block;  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>

9. In the code, replace /pages/terms-and-conditions with the URL of your terms and conditions page.

10. Click on Save.

Note: If the terms and conditions page doesn’t exist in your website, you will need to create the page.

If you get any trouble, please leave your queries in the comment box.

Thank you! have a great day.