skip to Main Content

WordPress Code Snippets


Easily Track Item Quantity and Units in Your WooCommerce Ca

To display units of measure with item quantities in the WooCommerce cart, modify the code. First, add a custom unit, like “kg” or “pcs.” Then, use the example below to show the unit next to the quantity.

add_filter('woocommerce_cart_item_quantity', 'show_cart_item_quantity', 10, 3);
function show_cart_item_quantity($quantity, $cart_item_key, $cart_item) {
    return $quantity . ' pcs'; // Append 'pcs' to quantity
}


I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search