Woocommerce在购物车页面显示产品的库存数量
默认情况下,Woocommerce的购物车页面是不显示产品的库存数量,在某些特殊的场景需求下,我们会让库存数量也显示在Woocommerce的购物车页面:
function fjj_stock_and_backorder_cart_item_title( $cart_item, $cart_item_key ) { $product = $cart_item['data']; if ( $product->backorders_require_notification() && $product->is_on_backorder( $cart_item['quantity'] ) ) return; echo wc_get_stock_html( $product ); } add_action( 'woocommerce_after_cart_item_name', 'fjj_stock_and_backorder_cart_item_title', 9999, 2 );