data min/max for variations
This commit is contained in:
parent
130d54779f
commit
d452f16129
|
@ -389,6 +389,18 @@ jQuery(document).ready(function($) {
|
|||
} else {
|
||||
$('.product_meta').find('.sku').text('');
|
||||
}
|
||||
|
||||
if (variation.min_qty) {
|
||||
$('.single_variation_wrap').find('input[name=quantity]').attr('data-min', variation.min_qty).val(variation.min_qty);
|
||||
} else {
|
||||
$('.single_variation_wrap').find('input[name=quantity]').removeAttr('data-min');
|
||||
}
|
||||
|
||||
if (variation.max_qty) {
|
||||
$('.single_variation_wrap').find('input[name=quantity]').attr('data-max', variation.max_qty);
|
||||
} else {
|
||||
$('.single_variation_wrap').find('input[name=quantity]').removeAttr('data-max');
|
||||
}
|
||||
|
||||
$('.single_variation_wrap').slideDown('200').trigger('variationWrapShown').trigger('show_variation'); // depreciated variationWrapShown
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -330,15 +330,17 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
|
|||
$image_link = '';
|
||||
}
|
||||
|
||||
$available_variations[] = array(
|
||||
$available_variations[] = apply_filters('woocommerce_available_variation', array(
|
||||
'variation_id' => $variation->get_variation_id(),
|
||||
'attributes' => $variation_attributes,
|
||||
'image_src' => $image,
|
||||
'image_link' => $image_link,
|
||||
'price_html' => '<span class="price">'.$variation->get_price_html().'</span>',
|
||||
'availability_html' => $availability_html,
|
||||
'sku' => __('SKU:', 'woocommerce') . ' ' . $variation->sku
|
||||
);
|
||||
'sku' => __('SKU:', 'woocommerce') . ' ' . $variation->sku,
|
||||
'min_qty' => 1,
|
||||
'max_qty' => $variation->stock
|
||||
), $product, $variation);
|
||||
}
|
||||
}
|
||||
woocommerce_get_template('single-product/add-to-cart/variable.php', array(
|
||||
|
|
Loading…
Reference in New Issue