Home » WooCommerce: Add “Quantity” Label in front of Add to Cart Button

WooCommerce: Add “Quantity” Label in front of Add to Cart Button

by Tutor Aspire

Here’s another little WooCommerce tweak for your website user experience: let’s add a string just in front of the Add to Cart button that says “Quantity: “. As usual, the biggest thing is looking for the right “hook”… but thankfully WooCommerce plugin is full of them and adding a string where we want is so easy 🙂

Add “quantity” label before Add to Cart @ Single Product Page

PHP Snippet: Add “Quantity” Label in front of Add to Cart Button – WooCommerce

/**
 * @snippet       Add "Quantity" Label in front of Add to Cart Button - WooCommerce
 * @how-to        Get tutoraspire.com FREE
 * @sourcecode    https://tutoraspire.com/?p=21986
 * @author        Tutor Aspire
 * @testedwith    WC 3.5.1
 * @donate $9     https://www.tutoraspire.com
 */

add_action( 'woocommerce_before_add_to_cart_quantity', 'tutoraspire_echo_qty_front_add_cart' );

function tutoraspire_echo_qty_front_add_cart() {
 echo '
Quantity:
'; }

And a couple of CSS lines as well:

div.qty {
    float: left;
    padding: 10px;
}

You may also like