Home Change Woocommerce product quantity in checkout table
Reply: 1

Change Woocommerce product quantity in checkout table

Madita von Birkenlund
1#
Madita von Birkenlund Published in 2018-01-12 18:58:29Z

I would like to change the way Woocommerce is displaying the product quantity in the order review table. I would like the quantity to be underneath the product name instead of after it.

I found this post which helped, but the code only changes the quantity layout for variable products.

How can I change it for EVERY product, even simple ones?

LoicTheAztec
2#
LoicTheAztec Reply to 2018-01-12 20:18:07Z

This can be done in multiple ways:

1) Overriding template checkout/review-order.php via your child theme.

2) Customizing the product item name:

add_filter( 'woocommerce_cart_item_name', 'customizing_checkout_item_name', 10, 3);
function customizing_checkout_item_name( $item_name, $cart_item, $cart_item_key ) {
    if( is_checkout() )
        $item_name .= '<br>';

    return $item_name;
}

Code goes in function.php file of the active child theme (or active theme).

3) Customizing the product item quantity (the best way):

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:') . ' <strong>' . $cart_item['quantity'] . '</strong></span>';

    return $quantity_html;
}

Code goes in function.php file of the active child theme (or active theme).

All code is tested and works.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.343064 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO