Would you like to add an Add quantity label before quantity field in woocommerce?
Hah… that’s easy,
Add the following snippet in your theme’s functions.php file make sure you are using a child theme or use code snippet plugin.
add_action( 'woocommerce_before_add_to_cart_quantity', 'wp_echo_qty_front_add_cart' );
function wp_echo_qty_front_add_cart() {
echo '<div class="qty">Quantity </div>';
}
After you add the above snippet the label may appear on top of Quantity field
Something like this will do.
div.qty {
float: left;
padding: 10px;
}
Where to add the code snippet
You need to add this code to your child functions.php
Please don’t add custom code directly to your parent functions.php
Why add Quantity Label in front of Quantity field?
There is no direct benefit of adding ‘Quantity’ label on the
Though it’s not necessary but could look cook in many theme design scenarios. So, it’s up to you to decide if it will be helpful for your users or look good on your product page.
If you liked this article, then please follow us on Facebook for more WooCommerce and WordPress tutorials. You can also find us on Twitter.
What are your thoughts, Do you think to add Quantity label before the quantity field is a good idea or not?
Oh, That was easy… Thanks’ it works
You’re Welcome!
Simple and easy, thanks!
Is it possible to have the label float left and the quantity box float right? the add to cart button in a new line floating right?
Of course, it’s possible, you need to do that with CSS
div.qty {
float: left;
padding: 10px;
}