WC_Product_Variation::get_stock_quantity( string $context = 'view' )

Returns number of items available for sale.


Description Description


Parameters Parameters

$context

(Optional) What the value is for. Valid values are view and edit.

Default value: 'view'


Top ↑

Return Return

(int|null)


Top ↑

Source Source

File: includes/class-wc-product-variation.php

	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;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.