wc_get_low_stock_amount( WC_Product $product )
Return low stock amount to determine if notification needs to be sent
Description Description
Since 5.2.0, this function no longer redirects from variation to its parent product. Low stock amount can now be attached to the variation itself and if it isn’t, only then we check the parent product, and if it’s not there, then we take the default from the store-wide setting.
Parameters Parameters
- $product
-
(Required) Product to get data from.
Return Return
(int)
Source Source
File: includes/wc-stock-functions.php
function wc_get_low_stock_amount( WC_Product $product ) { if ( $product->is_type( 'variation' ) ) { $product = wc_get_product( $product->get_parent_id() ); } $low_stock_amount = $product->get_low_stock_amount(); if ( '' === $low_stock_amount ) { $low_stock_amount = get_option( 'woocommerce_notify_low_stock_amount', 2 ); } return $low_stock_amount; }
Changelog Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |