This commit is contained in:
Mike Jolley 2012-02-17 23:47:18 +00:00
parent a533953779
commit 1a06f85b6d
6 changed files with 19 additions and 7 deletions

View File

@ -145,9 +145,19 @@ jQuery(document).ready(function($) {
});
$(".minus").live('click', function() {
var currentVal = parseInt($(this).next(".qty").val());
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 1;
if (currentVal > 0) $(this).next(".qty").val(currentVal - 1);
var currentVal = parseInt($(this).next(".qty").val());
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
$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 */

File diff suppressed because one or more lines are too long

View File

@ -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
* Fixed permalinks in shortcodes
* Install process tweaks (for flushing post type rules)
* data-min argument/option for quantity inputs
= 1.4.3 - 16/02/2012 =
* Fix for variation shipping class detection

View File

@ -3,4 +3,4 @@
* 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>

View File

@ -31,7 +31,7 @@ if( $product->get_price() === '') return;
<?php
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>

View File

@ -362,7 +362,8 @@ if (!function_exists('woocommerce_quantity_input')) {
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => ''
'max_value' => '',
'min_value' => '0'
);
$args = wp_parse_args( $args, $defaults );