Woocommerce在购物车页面显示产品的SKU
默认情况下,Woocommerce的购物车页面是不显示产品的SKU,在某些特殊的场景需求下,我们会让SKU也显示在Woocommerce的购物车页面:
function fjj_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>'; } add_action( 'woocommerce_after_cart_item_name', 'fjj_sku_below_cart_item_name', 11, 2 );