Merge pull request #25418 from helgatheviking/feature/quantity-placeholders

Add support for placeholders in quantity inputs
This commit is contained in:
Claudio Sanches 2020-02-04 14:05:39 -03:00 committed by GitHub
commit e0ee96cd37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -1677,6 +1677,7 @@ if ( ! function_exists( 'woocommerce_quantity_input' ) ) {
'pattern' => apply_filters( 'woocommerce_quantity_input_pattern', has_filter( 'woocommerce_stock_amount', 'intval' ) ? '[0-9]*' : '' ),
'inputmode' => apply_filters( 'woocommerce_quantity_input_inputmode', has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'numeric' : '' ),
'product_name' => $product ? $product->get_title() : '',
'placeholder' => apply_filters( 'woocommerce_quantity_input_placeholder', '', $product ),
);
$args = apply_filters( 'woocommerce_quantity_input_args', wp_parse_args( $args, $defaults ), $product );

View File

@ -12,7 +12,7 @@
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.6.0
* @version 3.10.0
*/
defined( 'ABSPATH' ) || exit;
@ -41,6 +41,7 @@ if ( $max_value && $min_value === $max_value ) {
value="<?php echo esc_attr( $input_value ); ?>"
title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ); ?>"
size="4"
placeholder="<?php echo esc_attr( $placeholder ); ?>"
inputmode="<?php echo esc_attr( $inputmode ); ?>" />
<?php do_action( 'woocommerce_after_quantity_input_field' ); ?>
</div>

View File

@ -12,7 +12,7 @@
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.4.0
* @version 3.10.0
*/
defined( 'ABSPATH' ) || exit;
@ -65,9 +65,10 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
woocommerce_quantity_input(
array(
'input_name' => 'quantity[' . $grouped_product_child->get_id() . ']',
'input_value' => isset( $_POST['quantity'][ $grouped_product_child->get_id() ] ) ? wc_stock_amount( wc_clean( wp_unslash( $_POST['quantity'][ $grouped_product_child->get_id() ] ) ) ) : 0, // WPCS: CSRF ok, input var okay, sanitization ok.
'input_value' => isset( $_POST['quantity'][ $grouped_product_child->get_id() ] ) ? wc_stock_amount( wc_clean( wp_unslash( $_POST['quantity'][ $grouped_product_child->get_id() ] ) ) ) : '', // WPCS: CSRF ok, input var okay, sanitization ok.
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 0, $grouped_product_child ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $grouped_product_child->get_max_purchase_quantity(), $grouped_product_child ),
'placeholder' => '0',
)
);