WC_Product::get_max_purchase_quantitypublicWC 3.0.0

Get max quantity which can be purchased at once.

Method of the class: WC_Product{}

Hooks from the method

Returns

Int|float. Quantity or -1 if unlimited.

Usage

$WC_Product = new WC_Product();
$WC_Product->get_max_purchase_quantity();

Changelog

Since 3.0.0 Introduced.

WC_Product::get_max_purchase_quantity() code WC 10.4.3

public function get_max_purchase_quantity() {
	/**
	 * Filters the maximum quantity which can be purchased at once.
	 *
	 * @since 10.1.0
	 * @param int|float $quantity The maximum quantity.
	 * @param \WC_Product $this The product object.
	 * @return int|float The maximum quantity.
	 */
	return wc_stock_amount( apply_filters( 'woocommerce_quantity_input_max', $this->is_sold_individually() ? 1 : ( $this->backorders_allowed() || ! $this->managing_stock() ? -1 : $this->get_stock_quantity() ), $this ) );
}