Automattic\WooCommerce\StoreApi\Utilities

QuantityLimits::get_add_to_cart_limits()publicWC 1.0

Get limits for product add to cart forms.

{} Это метод класса: QuantityLimits{}

Хуков нет.

Возвращает

Массив.

Использование

$QuantityLimits = new QuantityLimits();
$QuantityLimits->get_add_to_cart_limits( $product );
$product(\WC_Product) (обязательный)
Product instance.

Код QuantityLimits::get_add_to_cart_limits() WC 6.8.0

public function get_add_to_cart_limits( \WC_Product $product ) {
	$multiple_of = $this->filter_value( 1, 'multiple_of', $product );
	$minimum     = $this->filter_value( 1, 'minimum', $product );
	$maximum     = $this->filter_value( $this->get_product_quantity_limit( $product ), 'maximum', $product );

	return [
		'minimum'     => $this->limit_to_multiple( $minimum, $multiple_of, 'ceil' ),
		'maximum'     => $this->limit_to_multiple( $maximum, $multiple_of, 'floor' ),
		'multiple_of' => $multiple_of,
	];
}