WooCommerce: Show SKU @ Cart, Checkout, Order & Emails

When SKU matters to the end user, displaying it in the Cart page, Checkout page, Thank you page, My Account View Order page and Order Emails under the item name is a must.

Ideal for B2B businesses and international brands, this simple customization can help you learn how to add any sort of content under the Cart/Checkout/Order item names. Simply use the same hook and try “getting” something different than SKU with this guide. Enjoy!

With this handy snippet, echoing the SKU under each item in the Cart page is a breeze!

PHP Snippet: Display SKU Below Item Names @ Cart, Checkout, Order, Emails

/**
 * @snippet       Show SKU @ WooCommerce Cart
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 5
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

// First, let's write the function that returns a given product SKU
function bbloomer_return_sku( $product ) {
   $sku = $product->get_sku();
   if ( ! empty( $sku ) ) {
		return '<p>SKU: ' . $sku . '</p>';
	} else {
		return '';
	}
}

// This adds the SKU under cart/checkout item name
add_filter( 'woocommerce_cart_item_name', 'bbloomer_sku_cart_checkout_pages', 9999, 3 );

function bbloomer_sku_cart_checkout_pages( $item_name, $cart_item, $cart_item_key  ) {
	$product = $cart_item['data'];
   $item_name .= bbloomer_return_sku( $product );
   return $item_name;
}

// This adds SKU under order item table name
add_action( 'woocommerce_order_item_meta_start', 'bbloomer_sku_thankyou_order_email_pages', 9999, 4 );

function bbloomer_sku_thankyou_order_email_pages( $item_id, $item, $order, $plain_text ) {
	$product = $item->get_product();
   echo bbloomer_return_sku( $product );
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

16 thoughts on “WooCommerce: Show SKU @ Cart, Checkout, Order & Emails

  1. Works like a charm! I’m using Riode Theme.

  2. Hi, Thank you for creating a very useful snippet to add SKU on cart, checkout, email and order detail pages. It is working correctly on Cart, checkout and order details page. However in an email, it is adding SKU value two times in this format.

    Product title (# SKU-value)
    SKU: SKU-value

    Any reason, why is it adding the value of SKU two times in an order confirmation email?

    1. Hi Manish, thanks for that! Do you use any email customizer plugin? If not, could you send me a screenshot?

  3. It’s adding empty   code after SKU code.

    1. Weird, screenshot please?

  4. Hi is there any way to add a SKU on a email quote.

    1. Hi Kyle, what do you mean by “email quote”?

  5. Not working for me ๐Ÿ™ – using Avada theme…

    1. Not working anywhere? Avada may be customizing WooCommerce templates/function so it may need further customization

      1. Hello, has this issue been fixed for the Avada theme?

        1. Hi Drew, thanks so much for your comment! I’m afraid this is custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  6. It still works and it looks really nice. What about the checkout page (order summary)?

    1. Should work there too out of the box

  7. Yes it still works (2021). Works on the cart page/checkout but not on mini cart.

    1. Cool! The mini cart will require an additional piece of code

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.