A simple, powerful and independent e-commerce platform.
Sell anything with ease.

Show SKU in the cart

In some shops the SKU is a very important reference for the customer, so it can be useful to show it with the product name on the cart. This allows the customer to double check they are ordering exactly the item they need. This code adds the SKU (if there is one) under the product name on the cart.

		/**
 * Show SKU in the cart
 */

// Displays the SKU for a product (if it exists) below the product name in the cart
// https://www.businessbloomer.com/woocommerce-show-sku-cart-page/

add_action('woocommerce_after_cart_item_name', 'cc_show_sku_in_cart', 11, 2);

function cc_show_sku_in_cart($cart_item, $cart_item_key) {
  $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
  $sku = $_product->get_sku();
  if ( ! $sku ) return;
  echo '<p><small>SKU: ' . $sku . '</small></p>';
}
	
View Raw Code ID: 91211