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.
-
Go to “Online store”-> Select your live theme → Actions → Edit code
-
Select Assets folder, find theme.js
-
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.
-
Click Save, then go Sections->find Cart-template.liquid
-
Look for this code using Ctrl+F and search for cart.general.checkout
- Directly before the line <input type=“submit” name=“checkout” paste this code:
I agree with the terms and conditions.
So your final code looks like this:
** **** **** **I agree with the terms and conditions.** **** **
**-
Click Save, go check your shop if it works.
-
To disable “Buy now” button go to Online store → Customize
-
At the top left of the website preview (where Home Page is written by default) select “Product pages”
-
In the Sections click Product Pages and disable “Show dynamic checkout button”