Cart - Add an 'Agree to terms and conditions' checkbox

Worked great for me, thank you.
i wanted to have the T&C checkbox both in the cart and in the drawer (Refresh theme) so i had to tweak a bit the implementation.
i resolved it and put it here in case anyone has this use case:

  • what happens: the variable in the code “agree” will collide with both cart and cart drawer, you should have two variables one for each, like “agree” and agree2". otherwise even if you check the box on the drawer page (or cart page depends which loads first) you get the alert that you didn’t check the box.
  • how i solved it:
    • cart-drawer.liquid: use the code “as is” in this post.
    • main-cart-footer.liquid: also here i used the same codes provided in this post, but wherever it says “agree” I changed it to “agree2”
    • top theme.liquid file: use the code here “as is”
    • bottom of theme.liquid file: here you need to add the OR statement to check for either “agree” or “agree2” as its a global check. .
      so change this line:
      • if ($(‘#agree’).is(‘:checked’)) {
        $(this).submit();
        }
    • to this line:
      • if ($(‘#agree’).is(‘:checked’)||$(‘#agree2’).is(‘:checked’)) {
        $(this).submit();
        }

i hope it helps someone. and thanks again for this great post.
(PS a lot of comments here are about the “required” i didn’t have that issue in the Refresh theme)