@elisha_langworth
To add a quantity field on the shop page for WooCommerce, you can follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 |
function custom_quantity_input_field( $input, $product ) { if ( ! is_product() && ! is_cart() ) { return $input; } if ( ! $product->is_sold_individually() && $product->is_purchasable() ) { $input = '<input type="number" class="input-text qty text" step="1" min="1" max="' . $product->get_max_purchase_quantity() . '" name="quantity" value="' . $input . '" title="Qty" size="4" />'; } return $input; } add_filter( 'woocommerce_quantity_input', 'custom_quantity_input_field', 10, 2 ); |
This code will add a quantity input field for each product on the shop page, allowing customers to easily select the quantity they want to purchase.