In alcuni temi ottimizzati per WooCommerce, non viene mostrato il il codice ISKU (Stock Keeping Unit) nella pagina del carrello ed in quella del checkout. Per risolvere il problema, inseriremo all’interno del file functions.php del tema il codice seguente, che permetterà di mostrare il codice SKU anche per i prodotti variabili:
add_filter( 'woocommerce_cart_item_name', 'showing_sku_in_cart_items', 99, 3 );
function showing_sku_in_cart_items( $item_name, $cart_item, $cart_item_key ) {
$product = $cart_item['data'];
if (empty($product)) {
return $item_name;
}
$sku = $product->get_sku();
if (empty($sku)) {
return $item_name;
}
$item_name .= '
<small class="product-sku">' . __( "SKU: ", "woocommerce") . $sku . '</small>';
return $item_name;
}








