New CheckBox not working

Please post your issues and questions about One Page Checkout for Virtuemart 2 to this forum.

New CheckBox not working

Postby alletom79@.....com » Wed Nov 04, 2015 4:55 pm

Hi, I need a new checkbox to put in the checkout template threecolumn_special_blue_css3, it is a single selection checkbox that the customers can use to require the items packed in a gift package. To do that I added a new checkbox field in Virtuemart Shopper Field and I gave to it the name "confezione_regalo", then I checked "confezione_regalo" also in OPC Shopper Field tab on the "Custom OPC rendering" column, all the other field columns are unchecked.
I also added the following code to the template files onepage.logged.tpl.php and onepage.unlogged.tpl.php

Code: Select all
<div class="right_label"><label for="confezione_regalo">Confezionare in carta regalo (Gratis)
<input value="1" type="checkbox" id="confezione_regalo"  name="confezione_regalo">
</label>
</div>


As the result now I can see this checkbox in the checkout template, but if I complete the order with the checkbox marked, the order details show always unchecked...

Can you please help to fix it?

Best regards
Alessandro
alletom79@.....com
 
Posts: 5
Joined: Mon Jun 29, 2015 9:06 pm

Re: New CheckBox not working

Postby admin » Wed Nov 04, 2015 5:32 pm

hello alessandro,

i can check this on your site if you'd like.

it should be marked as "published" + "show in account" (OR "cart field" + OPC order field) + OPC custom rendered

pls contact me on our live chat, i am going to recreate this case on my demos now.

please let me know if you marked it as:
- show in account OR show in cart ( in VM config)
- order field only (in OPC config)

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: New CheckBox not working

Postby admin » Wed Nov 04, 2015 5:38 pm

also - make sure it renders inside OPC's main form (inside <form ... and </form> ) tags in onepage.unlogged + logged.php files.

if not, you/me would need to create a further code:
1. inside the OPC form code add this:
Code: Select all
<input type="hidden" value=""  id="confezione_regalo_field" name="confezione_regalo" />

2. modify your own code:
Code: Select all
<div class="right_label"><label for="confezione_regalo">Confezionare in carta regalo (Gratis)
<input value="1" type="checkbox" id="confezione_regalo"  name="confezione_regalo" onchange="updateMyCheckbox(this);" >
</label>
</div>
<script>
function updateMyCheckbox(el) {
var d = document.getElementById('confezione_regalo_field');
var value = el.value;
if (!el.checked) value = '';
if (d != null) d.value = value;
}
</script>


i didn't test the above code.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: New CheckBox not working

Postby admin » Wed Nov 04, 2015 5:57 pm

ok, i now tested with this config:

- VM field marked as published + show in cart form
- OPC: order field only + custom rendered (opc 301 give s notice about the cart field, just ignore it)
- the field is shown in order emails properly as checked BUT it is not shown in emails

i tested on vm3.0.11.4 (should be about the same as vm3.0.10 official) + OPC 3.0.301 (my DEV build)

i am going to check if it works when the field is marked as:
- show in account maintains + published (VM config)
- in OPC only as customer rendered (no other config)

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: New CheckBox not working

Postby admin » Wed Nov 04, 2015 6:00 pm

ok, the second test was ok as well, but compared to "show in cart form" config, it also showed the field in EMAILS -> it used the Field name there (it didn't show the value - 1 within the emails)

i think you only need to update your code so it's inside the checkout form.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: New CheckBox not working

Postby alletom79@.....com » Wed Nov 04, 2015 8:36 pm

Hi Stan, thanks for your Kind reply.
I tried your solution exactly as you described, but on my website is nor working. I saw that you did a test on vm3.0.11.4 and OPC 3.0.301, but I have in use vm 2.6.14 and OPC 2.0.292.160615

Could be that the problem?

Best Regards
Alessandro
alletom79@.....com
 
Posts: 5
Joined: Mon Jun 29, 2015 9:06 pm

Re: New CheckBox not working

Postby alletom79@.....com » Thu Nov 05, 2015 1:50 pm

Thanks for the great support by live chat Stan.
Finally the solution was keep the Checkbox inside the <form>...</form> and in VM2 enable:
- Show in registration form
- Show in account maintenance

Well Done!
Alessandro
alletom79@.....com
 
Posts: 5
Joined: Mon Jun 29, 2015 9:06 pm


Return to One Page Checkout for Virtuemart 2

cron