WC_Product_Variation::get_stock_quantity
Returns number of items available for sale.
Method of the class: WC_Product_Variation{}
Hooks from the method
Returns
Int|null.
Usage
$WC_Product_Variation = new WC_Product_Variation(); $WC_Product_Variation->get_stock_quantity( $context );
- $context(string)
- What the value is for. Valid values are view and edit.
Default:'view'
WC_Product_Variation::get_stock_quantity() WC Product Variation::get stock quantity code WC 10.5.0
public function get_stock_quantity( $context = 'view' ) {
$value = $this->get_prop( 'stock_quantity', $context );
// Inherit value from parent.
if ( 'view' === $context && 'parent' === $this->get_manage_stock() ) {
$value = apply_filters( $this->get_hook_prefix() . 'stock_quantity', $this->parent_data['stock_quantity'], $this );
}
return $value;
}