MainWP Community

Display stock on the cart page in WooCommerce

Display stock on the cart page in WooCommerce on your child site.

Snippet Type

Execute on Child Sites

Snippet

add_action( 'woocommerce_after_cart_item_name', 'wc_stock_and_backorder_cart_item_title', 9999, 2 );
 
function wc_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 );
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.