Allow variations JS to be used on multiple products in the same form
This commit is contained in:
parent
f0fe86a8ac
commit
3af1df55c7
|
@ -42,7 +42,7 @@
|
|||
// On clicking the reset variation button
|
||||
.on( 'click', '.reset_variations', function( event ) {
|
||||
|
||||
$(this).closest('form.variations_form').find('.variations select').val('').change();
|
||||
$(this).closest('.variations_form').find('.variations select').val('').change();
|
||||
|
||||
var $sku = $(this).closest('.product').find('.sku');
|
||||
var $weight = $(this).closest('.product').find('.product_weight');
|
||||
|
@ -63,7 +63,7 @@
|
|||
// Upon changing an option
|
||||
.on( 'change', '.variations select', function( event ) {
|
||||
|
||||
$variation_form = $(this).closest('form.variations_form');
|
||||
$variation_form = $(this).closest('.variations_form');
|
||||
$variation_form.find('input[name=variation_id]').val('').change();
|
||||
|
||||
$variation_form
|
||||
|
@ -81,7 +81,7 @@
|
|||
// Upon gaining focus
|
||||
.on( 'focusin touchstart', '.variations select', function( event ) {
|
||||
|
||||
$variation_form = $(this).closest('form.variations_form');
|
||||
$variation_form = $(this).closest('.variations_form');
|
||||
|
||||
$variation_form
|
||||
.trigger( 'woocommerce_variation_select_focusin' )
|
||||
|
@ -221,7 +221,7 @@
|
|||
// Disable option fields that are unavaiable for current set of attributes
|
||||
.on( 'update_variation_values', function( event, variations ) {
|
||||
|
||||
$variation_form = $(this).closest('form.variations_form');
|
||||
$variation_form = $(this).closest('.variations_form');
|
||||
|
||||
// Loop through selects and disable/enable options based on selections
|
||||
$variation_form.find('.variations select').each(function( index, el ) {
|
||||
|
@ -410,8 +410,8 @@
|
|||
};
|
||||
|
||||
$(function() {
|
||||
$('form.variations_form').wc_variation_form();
|
||||
$('form.variations_form .variations select').change();
|
||||
$('.variations_form').wc_variation_form();
|
||||
$('.variations_form .variations select').change();
|
||||
});
|
||||
|
||||
})( jQuery, window, document );
|
Loading…
Reference in New Issue