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 CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=21986
 * @author        Rodolfo Melogli
 * @testedwith    WC 3.5.1
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_action( 'woocommerce_before_add_to_cart_quantity', 'bbloomer_echo_qty_front_add_cart' );

function bbloomer_echo_qty_front_add_cart() {
 echo '<div class="qty">Quantity: </div>'; 
}

And a couple of CSS lines as well:


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

Share:

Leave a Reply