How to Show SKU on the Cart Page

If you want to display your SKU on the cart and checkout pages, simply add this code to your child theme in the functions.php file. It hooks into the action “woocommerce_cart_item_name” which is perfect.

You can add the following Snippet to Functions.php

/**
 * @snippet       Show SKU @ WooCommerce Cart
 * @author        codeithub
*/
 
add_action( 'woocommerce_after_cart_item_name', 'codeithub_sku_below_cart_item_name', 11, 2 );
 
function codeithub_sku_below_cart_item_name( $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>';
}

Before:

See also  Display Regular & Sale Price on Cart Table
Cart page of Woocommerce

After:

SKU on the cart Page

Leave a Reply

Your email address will not be published. Required fields are marked *