Hello,
i am using WooCommerce + Enfold.
I would like to add a quantity counter below the “add to cart” bottons at our product site, below the product itself.
The red box indicates where i want the buttons to be – optimally inside the product window.
This is what i mean with a quantity counter
Anyway to do this with shortcode? I am not to familar with CSS or HTML – but i can work with those if there is any code i can tweak till it fits the purpose.
Thanks in advance! Best wishes, Niclas
Hey NThiem,
Thank you for the inquiry.
You can use this code in the functions.php file to add the quantity buttons to the product overview page.
add_filter( 'woocommerce_loop_add_to_cart_link', function( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="avia-quantity-button" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
}
return $html;
}, 10, 2 );
Please make sure that the Enfold > Shop Options > Product layout on overview pages is set to Default or the very first option.
Best regards,
Ismael