Merge pull request #8407 from justinshreve/quantity-improvements
Remember the user's quantity selection if a validation error occurs
This commit is contained in:
commit
8284d01ec4
|
@ -38,7 +38,12 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
|||
<?php else : ?>
|
||||
<?php
|
||||
$quantites_required = true;
|
||||
woocommerce_quantity_input( array( 'input_name' => 'quantity[' . $product_id . ']', 'input_value' => '0', 'min_value' => apply_filters( 'woocommerce_quantity_input_min', 0, $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product ) ) );
|
||||
woocommerce_quantity_input( array(
|
||||
'input_name' => 'quantity[' . $product_id . ']',
|
||||
'input_value' => ( isset( $_POST['quantity'][$product_id] ) ? wc_stock_amount( $_POST['quantity'][$product_id] ) : 0 ),
|
||||
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 0, $product ),
|
||||
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product )
|
||||
) );
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
|
|
@ -35,11 +35,13 @@ if ( ! $product->is_purchasable() ) {
|
|||
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
|
||||
|
||||
<?php
|
||||
if ( ! $product->is_sold_individually() )
|
||||
if ( ! $product->is_sold_individually() ) {
|
||||
woocommerce_quantity_input( array(
|
||||
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
|
||||
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product )
|
||||
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
|
||||
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product ),
|
||||
'input_value' => ( isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 )
|
||||
) );
|
||||
}
|
||||
?>
|
||||
|
||||
<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
|
||||
|
|
|
@ -76,7 +76,9 @@ global $product, $post;
|
|||
<div class="single_variation"></div>
|
||||
|
||||
<div class="variations_button">
|
||||
<?php woocommerce_quantity_input(); ?>
|
||||
<?php woocommerce_quantity_input( array(
|
||||
'input_value' => ( isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 )
|
||||
) ); ?>
|
||||
<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue