Hi there everybody so i’ve figured it out myself and instead of telling you I figured it out, I am actually going to reveal to you how to do it.
I am using debut theme, yet I wonder if this is the reason why most people cannot get it to work in the other themes.
The trick is adding this code in a new custom.js file, as debut theme preloads theme.js and I think this is why as most people will add jquery below this file, so it loads before jquery causing it not to work. So creating a new file and keeping it separate works better:
$(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;
}
});
});
So find where you added your jquery and make sure this new custom.js file is in the code below it.
So where I have jqeury loading in theme.liquid in the header:
: I added my new custom.s file with the code in it right below. Just like this, on a new line right below.{{ ‘custom.js’ | asset_url | script_tag }}
Hopefully this helps. ![]()