Hello, I am running into a conflict when I display multiple products on one page with the Woocommerce GF add-on because they use the same form and am looking for an innovative solution.
Example page: https://hookahi.com/guides/hucks-charters/
EDIT----
The problem turned out to be with some jquery I have in. This is the code:
jQuery(document).ready(function($) {
$(".cart").submit(function() {
if (document.getElementById('choice_8_1').checked)
return true;
else if (document.getElementById('choice_8_0').checked)
return true;
else return false;
});
});
The problem is there are multiple elements with that ID (because it is the same form repeating). So I either need a way to assign unique values to those radio choices, or a different way to require the element of each item be checked (replace the code above).
Christianto answers:
You can try to use each field class and select each checkbox input by its object index ,
I check that it has class="payment_options", so the code:
$(".cart").submit(function() {
// search for all payment radio input
var payment = $('.payment_options input:radio', this);
if (payment.eq(0).is(':checked')) // if 1st checkbox option checked ( full payment )
return true; // your action if input full payment checked
else if (payment.eq(1).is(':checked')) // if 2nd checkbox option checked ( Deposit payment )
return true; // your action if input deposit payment checked
else
return false;
});
or
$(".cart").submit(function() {
// search for all payment radio input
var payment = $('.payment_options input:radio', this);
// if 1st and 2nd checkbox option checked ( Full and Deposit payment )
if (payment.eq(0).is(':checked') || payment.eq(1).is(':checked'))
return true;
else
return false;
});
Kyle comments:
This issue was actually just recently solved by an outside developer. I do have a new issue though with the same page and area.
If you notice now the other problem was solved, but if you click the text (not the actual radio button, but the text label) of a payment option for the 2nd or 3rd items, it selects the radio button for the first. If you click the actual button though it works properly.
Here is the template for reference: http://pastie.org/private/vjad1qxyc1datmanzt2aq
You wrote the datepicker part haha
Christianto comments:
The label pointing to each input id, because there is more than 1 id, it will affect other checkbox input as well,
you can remove the id for each label if you want, I think for label it won't affect anything.
jQuery('.gchoice_8_0 label,.gchoice_8_1 label').attr('for','');
Kyle comments:
That works, thank you