I want to hide the product quantity in the WooCommerce Checkout and replace the “x 1” next to the title with an extra line below the product title.
But it should show the quantity of the product only if there are more than 1 of it in the order.
I found the following code which adds the extra line for the quantity. But I couldn’t figure out how to display the quantity only if there is > 1 product in the order.
add_filter( 'woocommerce_checkout_cart_item_quantity', 'customizing_checkout_item_quantity', 10, 3);
function customizing_checkout_item_quantity( $quantity_html, $cart_item, $cart_item_key ) {
$quantity_html = ' <br>
<span class="product-quantity">' . __('Quantity', 'woocommerce') . ': <strong>' . $cart_item['quantity'] . '</strong></span>';
return $quantity_html;
}
Code is from this answer: https://stackoverflow.com/a/48233426/1788961
Is there any way to check the quantity and display the line only if there a more than 1 of the product in the order?
2
Answers
I figured it out. There is already the quantity in the functions:
This is my solution:
To check if there is more than one product per order, I’d go for the following condition: