Jump to content

Terms and conditions autochecked


Recommended Posts

  • 4 years later...

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

  • 6 months later...

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

  • 1 month later...

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

 

 

 

 

  • Like 1
Link to comment
Share on other sites

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 by cristidam (see edit history)
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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!

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...