zaglebie Posted July 28, 2011 Share Posted July 28, 2011 Hi, i want to have terms and conditions checkbox autochecked - how to do this ? Link to comment Share on other sites More sharing options...
Richard S Posted July 28, 2011 Share Posted July 28, 2011 You can use a javascript to do this and check it when the page is loaded. Link to comment Share on other sites More sharing options...
bellini13 Posted July 28, 2011 Share Posted July 28, 2011 in your themes order-carrier.tpl, change the following line so that checked="checked" all the time. <input type="checkbox" name="cgv" id="cgv" value="1" {if $checkedTOS}checked="checked"{/if} /> Link to comment Share on other sites More sharing options...
vivek tripathi Posted August 1, 2011 Share Posted August 1, 2011 Another way through jQuery by adding following code at the top in themes->order-carrier.tpl file <script type="text/javascript"> {literal} $('document').ready( function(){ $('#cgv').attr('checked','checked'); }); {/literal} </script> 1 Link to comment Share on other sites More sharing options...
nickosn Posted November 29, 2015 Share Posted November 29, 2015 Another way through jQuery by adding following code at the top in themes->order-carrier.tpl file <script type="text/javascript"> {literal} $('document').ready( function(){ $('#cgv').attr('checked','checked'); }); {/literal} </script> Hi, this does not seem to work on 1.6.0.14 Link to comment Share on other sites More sharing options...
AndyCZ Posted June 3, 2016 Share Posted June 3, 2016 I can confirm this script works it in 1.6.0.9 and 1.6.1.5 <script type="text/javascript"> {literal} $('document').ready( function(){ $('#cgv').attr('checked','checked'); }); {/literal} </script> thanks Link to comment Share on other sites More sharing options...
cristidam Posted July 16, 2016 Share Posted July 16, 2016 Hi, The checkbox is checked with this script, but the payment methods do not appear. I have to manually uncheck it, then check it again for the payment methods to show up, Can anyone help? Link to comment Share on other sites More sharing options...
bellini13 Posted July 17, 2016 Share Posted July 17, 2016 This is likely going to depend on your version of Prestashop, and/or the theme you are using In v1.6.1.6 using the default theme, the payment methods get displayed using the checkboxes 'on click' event. Checking the box using jquery does not trigger the on click event. This means that you may need to check the box, and trigger the click event The code to check the box is above The code to trigger the click event is below. $('#cgv').click(); I did not test this, so it is possible that triggering the click event also checks the box. Test it out and let us know 1 Link to comment Share on other sites More sharing options...
cristidam Posted July 17, 2016 Share Posted July 17, 2016 (edited) This is likely going to depend on your version of Prestashop, and/or the theme you are using In v1.6.1.6 using the default theme, the payment methods get displayed using the checkboxes 'on click' event. Checking the box using jquery does not trigger the on click event. This means that you may need to check the box, and trigger the click event The code to check the box is above The code to trigger the click event is below. $('#cgv').click(); I did not test this, so it is possible that triggering the click event also checks the box. Test it out and let us know Hi, I am using v 1.6.1.6 and your solution works well. thank you. As i expected, when the page is reloded or if the user needs to sign in (the page gets reloaded) the script unchecks the box so i think that for a perfect solution an if statment would be required. Unfortunately i don't have programing skills, but logically it should be something like this: if (#cgv) = unchecked then run ($('#cgv').click()) else (do nothing). Thank you! Edited July 17, 2016 by cristidam (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted July 17, 2016 Share Posted July 17, 2016 Sounds like you have the basic concepts understood. If it were me, i would spend some time doing a google search on how to use jquery or javascript and create the code you need. You could also look at the order-opc.js javascript file included with your theme, for plenty of code samples, and piece together the code you need 1 Link to comment Share on other sites More sharing options...
cristidam Posted July 18, 2016 Share Posted July 18, 2016 Hi, First of all i would like to thank you for not giving me the code instantly, this way i have learned a little javascript I used the following code which seems to work well on my website: <script type="text/javascript"> {literal} $('document').ready( function(){ if ($('#cgv:checked').length !== 1) { $('#cgv').click(); } }); {/literal} </script> I would like to ask you to verify if the code syntax and logic is corect. Thank you! 1 Link to comment Share on other sites More sharing options...
bellini13 Posted July 20, 2016 Share Posted July 20, 2016 Looks good to me, waits for the DOM to be ready, then checks if the TOC is not checked, and then clicks it. Thanks for coming back and sharing the solution 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now