Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions

Utils::get_product_quantity_constraintspublic staticWC 1.0

Get the quantity constraints for a product.

Method of the class: Utils{}

No Hooks.

Returns

Array. The quantity constraints.

Usage

$result = Utils::get_product_quantity_constraints( $product );
$product(WC_Product) (required)
The product to get the quantity constraints for.

Utils::get_product_quantity_constraints() code WC 10.3.6

public static function get_product_quantity_constraints( $product ) {
	$min          = is_numeric( $product->get_min_purchase_quantity() ) ? $product->get_min_purchase_quantity() : 1;
	$max_quantity = $product->get_max_purchase_quantity();
	$max          = is_numeric( $max_quantity ) && -1 !== $max_quantity ? $max_quantity : null;
	$step         = is_numeric( $product->get_purchase_quantity_step() ) ? $product->get_purchase_quantity_step() : 1;

	return array(
		'min'  => $min,
		'max'  => $max,
		'step' => $step,
	);
}