How to Show SKU Code on WooCommerce Cart Page

When SKU Code is important to the end-users, then displaying it in the Cart page under each item’s name is a must.

PHP Snippet: Show SKU Code on WooCommerce Cart Page

/**
 * @snippet       Show SKU @ WooCommerce Cart
 * @how-to        Get codeithub.com FREE
 * @author        Arun
 * @testedwith    WooCommerce 4.1
 * @donate        https://codeithub.com
 */
 
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>';
}
See also  How to Change WooCommerce Variation Dropdown Text

Leave a Reply