The snippet that adds product SKU after cart item name in cart, mini-cart and checkout:
function show_sku_in_cart_items( $item_name, $cart_item, $cart_item_key ) {
// The WC_Product object
$product = $cart_item['data'];
// Get the SKU
$sku = $product->get_sku();
// When sku doesn't exist
if ( empty( $sku ) )
return $item_name;
// Add the sku
if ( is_cart() ) {
$item_name .= '<br><small class="product-sku">' . '<span class="sku-title">' . __( "SKU: ", "woocommerce") . '</span>' . $sku . '</small>';
} else {
$item_name .= '<small class="product-sku">' . $sku . '</small>';
}
return $item_name;
}
add_filter( 'woocommerce_cart_item_name', 'show_sku_in_cart_items', 99, 3 );
I need to add this before cart item name