I want to show the stock status for every product in cart with the status "few in stock".
Like this:
Productname
Size: L
Only 4 left <- this is new
I found a snippet to show the stock status on shop pages:
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_show_stock_shop', 10 );
function bbloomer_show_stock_shop() {
global $product;
echo wc_get_stock_html( $product );
}
Source: https://businessbloomer.com/woocommerce-add-stock-quantity-on-shop-page/
I tried to change the hook from woocommerce_after_shop_loop_item
to woocommerce_after_cart_item_name
to display the status below the title in the cart.
But the snippet doesn't work.
Also I have no idea how to limit it to items with a low stock.