Hi,
I need to display different units next to the quantity button depending on the type of my products. So, I included an individual label for each product as you suggest:
#product-211 .quantity:after {content:”Unit01″; margin-left:10px}
#product-212 .quantity:after {content:”Unit02″; margin-left:10px}
etc…
However, I also need to include the quantity button with its corresponding label within my shop archive pages and I found the following code to do it (https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/).
<?php
/**
* Code should be placed in your theme functions.php file.
*/
add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘quantity_inputs_for_woocommerce_loop_add_to_cart_link’, 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $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=”cart” 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;
}
With this code, the quantity button appears in the shop archive pages but the unit label is missing. Could anybody help me with this?
Thank you very much.