Hello,
I have added the terms and conditions checkbox to my cart by following the many responses in the community. (code below for anyone interested). However, when I am on the cart page, the pop up activates as soon as you get to the cart page. If you close the prompt, DO NOT check off the box and click checkout, you are able to go to checkout with no issue.
I would like for two things:
-
For the pop up not to be automatic once you click on cart, but only if you try to click check out without checking the box.
-
For customers not to be able to move on to checkout unless the box is checked.
How can I edit the code below to accomplish these two things? Thank you!
main-cart-footer.liquid :###### ###### Add:######
###### ###### ###### I have agreed to the terms and conditions.###### ######
###### ######
cart.js :###### ######
Add to bottom:
if ($(‘#agree’).is(‘:checked’)) {###### $(this).submit();###### }###### else {###### alert(“You must agree with the Terms and Conditions to check out.”);###### return false;
Hello @thepaintedleaf ,
You need to have the below approach for getting this work done:-
By default, the checkout button should be disabled, once the customer clicks on the checkbox then the checkout button should be enabled and the customer will be able to checkout.
Html:-
Need to add the "disabled=‘true’ " attribute on the checkout button, to disable it by default.
JQuery code:
$(‘#agree’).change(function() {
if($(this).is(‘checked’)){
$(‘[name=“checkout”]’).removeAttr(‘disabled’);
}
else{
$(‘[name=“checkout”]’).attr(‘disabled’, true);
}
});
Hope it helps. Let us know if you need any help.
All the best,
CedCommerce
Hello @Cedcommerce ,
Thanks for your response. I am not sure where to plug that code in. I am using the Sense theme, and I tried plugging it into the cart.js code, main-cart-iems.liquid, main-cart-footer.liquid, cart-notification.liquid and I can’t get the checkbox greyed out.
Hello @thepaintedleaf ,
Thank you for reaching out to us. We will surely help you with this.
Just follow the below steps to add the code and fix your issue.
- Go to your Shopify admin > online store > select sense theme
- Click on action > edit code > search a file “main-cart-footer”
- In this file, you need to add the code
Hope it helps. Let us know if you need any further help.
All the best,
CedCommerce
Hey @thepaintedleaf , learn how to add a ‘Agree to Terms and Conditions’ checkbox to your Shopify cart without the need for apps by watching this concise video tutorial: https://www.youtube.com/watch?v=smyIqWWuZvs