data-min
This commit is contained in:
parent
a533953779
commit
1a06f85b6d
|
@ -146,8 +146,18 @@ jQuery(document).ready(function($) {
|
||||||
|
|
||||||
$(".minus").live('click', function() {
|
$(".minus").live('click', function() {
|
||||||
var currentVal = parseInt($(this).next(".qty").val());
|
var currentVal = parseInt($(this).next(".qty").val());
|
||||||
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 1;
|
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
|
||||||
if (currentVal > 0) $(this).next(".qty").val(currentVal - 1);
|
|
||||||
|
$qty = $(this).next(".qty");
|
||||||
|
|
||||||
|
var min = parseInt($qty.attr('data-min'));
|
||||||
|
if (min=="" || min == "NaN") min = 0;
|
||||||
|
|
||||||
|
if (min && (min==currentVal || currentVal<min)) {
|
||||||
|
$qty.val(min);
|
||||||
|
} else if (currentVal > 0) {
|
||||||
|
$qty.val(currentVal - 1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* states */
|
/* states */
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -92,6 +92,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
|
||||||
* Method availability (country) for local pickup/delivery
|
* Method availability (country) for local pickup/delivery
|
||||||
* Fixed permalinks in shortcodes
|
* Fixed permalinks in shortcodes
|
||||||
* Install process tweaks (for flushing post type rules)
|
* Install process tweaks (for flushing post type rules)
|
||||||
|
* data-min argument/option for quantity inputs
|
||||||
|
|
||||||
= 1.4.3 - 16/02/2012 =
|
= 1.4.3 - 16/02/2012 =
|
||||||
* Fix for variation shipping class detection
|
* Fix for variation shipping class detection
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
* Single Product Quantity Inputs
|
* Single Product Quantity Inputs
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<div class="quantity"><input name="<?php echo $input_name; ?>" data-max="<?php echo $max_value; ?>" value="<?php echo $input_value; ?>" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
|
<div class="quantity"><input name="<?php echo $input_name; ?>" data-min="<?php echo $min_value; ?>" data-max="<?php echo $max_value; ?>" value="<?php echo $input_value; ?>" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
|
|
@ -31,7 +31,7 @@ if( $product->get_price() === '') return;
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (!$product->is_downloadable())
|
if (!$product->is_downloadable())
|
||||||
woocommerce_quantity_input( array( 'max_value' => ($product->backorders_allowed()) ? '' : $product->get_stock_quantity() ) );
|
woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => ($product->backorders_allowed()) ? '' : $product->get_stock_quantity() ) );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<button type="submit" class="button alt"><?php _e('Add to cart', 'woocommerce'); ?></button>
|
<button type="submit" class="button alt"><?php _e('Add to cart', 'woocommerce'); ?></button>
|
||||||
|
|
|
@ -362,7 +362,8 @@ if (!function_exists('woocommerce_quantity_input')) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'input_name' => 'quantity',
|
'input_name' => 'quantity',
|
||||||
'input_value' => '1',
|
'input_value' => '1',
|
||||||
'max_value' => ''
|
'max_value' => '',
|
||||||
|
'min_value' => '0'
|
||||||
);
|
);
|
||||||
|
|
||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
|
|
Loading…
Reference in New Issue