diff --git a/bin/hook-docs/data/filters.json b/bin/hook-docs/data/filters.json index 379eb2cacdf..178329e58a3 100644 --- a/bin/hook-docs/data/filters.json +++ b/bin/hook-docs/data/filters.json @@ -815,94 +815,85 @@ "args": 1 }, { - "name": "woocommerce_store_api_item_quantity_minimum", - "file": "StoreApi/Schemas/CartItemSchema.php", + "name": "woocommerce_store_api_product_quantity_limit", + "file": "StoreApi/Utilities/QuantityLimits.php", "type": "filter", "doc": { - "description": "Filters the quantity minimum for a cart item in Store API.", - "long_description": "", + "description": "Filters the quantity limit for a product being added to the cart via the Store API.", + "long_description": "Filters the variation option name for custom option slugs.", "tags": [ { "name": "param", - "content": "Cart item array.", + "content": "Quantity limit which defaults to 99 unless sold individually.", "types": [ - "array" + "integer" ], - "variable": "$cart_item" + "variable": "$quantity_limit" }, - { - "name": "return", - "content": "", - "types": [ - "\\Automattic\\WooCommerce\\Blocks\\StoreApi\\Schemas\\number" - ] - } - ], - "long_description_html": "" - } - }, - { - "name": "woocommerce_store_api_item_quantity_step", - "file": "StoreApi/Schemas/CartItemSchema.php", - "type": "filter", - "doc": { - "description": "Filters the quantity increment for a cart item in Store API.", - "long_description": "", - "tags": [ { "name": "param", - "content": "Cart item array.", + "content": "Product instance.", "types": [ - "array" + "\\WC_Product" ], - "variable": "$cart_item" + "variable": "$product" }, { "name": "return", "content": "", "types": [ - "\\Automattic\\WooCommerce\\Blocks\\StoreApi\\Schemas\\number" + "integer" ] } ], - "long_description_html": "" - } + "long_description_html": "
Filters the variation option name for custom option slugs.
" + }, + "args": 2 }, { - "name": "woocommerce_store_api_product_quantity_limit", - "file": "StoreApi/Schemas/ProductSchema.php", + "name": "woocommerce_store_api_product_quantity_{$value_type}", + "file": "StoreApi/Utilities/QuantityLimits.php", "type": "filter", "doc": { - "description": "Filters the quantity limit for a product being added to the cart via the Store API.", - "long_description": "Filters the variation option name for custom option slugs.", + "description": "Filters the quantity minimum for a cart item in Store API. This allows extensions to control the minimum qty of items already within the cart.", + "long_description": "The suffix of the hook will vary depending on the value being filtered. For example, minimum, maximum, multiple_of, editable.", "tags": [ { "name": "param", - "content": "Quantity limit which defaults to 99 unless sold individually.", + "content": "The value being filtered.", "types": [ - "integer" + "mixed" ], - "variable": "$quantity_limit" + "variable": "$value" }, { "name": "param", - "content": "Product instance.", + "content": "The product object.", "types": [ "\\WC_Product" ], "variable": "$product" }, + { + "name": "param", + "content": "The cart item if the product exists in the cart, or null.", + "types": [ + "array", + "null" + ], + "variable": "$cart_item" + }, { "name": "return", "content": "", "types": [ - "integer" + "mixed" ] } ], - "long_description_html": "Filters the variation option name for custom option slugs.
" + "long_description_html": "The suffix of the hook will vary depending on the value being filtered. For example, minimum, maximum, multiple_of, editable.
" }, - "args": 2 + "args": 3 }, { "name": "woocommerce_variation_option_name", diff --git a/docs/extensibility/filters.md b/docs/extensibility/filters.md index 7a87746fbcf..db690f3e034 100644 --- a/docs/extensibility/filters.md +++ b/docs/extensibility/filters.md @@ -29,9 +29,8 @@ - [woocommerce_shipping_package_name](#woocommerce_shipping_package_name) - [woocommerce_show_page_title](#woocommerce_show_page_title) - [woocommerce_store_api_disable_nonce_check](#woocommerce_store_api_disable_nonce_check) - - [woocommerce_store_api_item_quantity_minimum](#woocommerce_store_api_item_quantity_minimum) - - [woocommerce_store_api_item_quantity_step](#woocommerce_store_api_item_quantity_step) - [woocommerce_store_api_product_quantity_limit](#woocommerce_store_api_product_quantity_limit) + - [woocommerce_store_api_product_quantity_{$value_type}](#woocommerce_store_api_product_quantity_-value_type) - [woocommerce_variation_option_name](#woocommerce_variation_option_name) --- @@ -694,89 +693,68 @@ apply_filters( 'woocommerce_store_api_disable_nonce_check', boolean $disable_non --- -## woocommerce_store_api_item_quantity_minimum +## woocommerce_store_api_product_quantity_limit -Filters the quantity minimum for a cart item in Store API. +Filters the quantity limit for a product being added to the cart via the Store API. ```php -apply_filters( 'woocommerce_store_api_item_quantity_minimum', array $cart_item ) +apply_filters( 'woocommerce_store_api_product_quantity_limit', integer $quantity_limit, \WC_Product $product ) ``` -### Parameters - -| Argument | Type | Description | -| -------- | ---- | ----------- | -| $cart_item | array | Cart item array. | - -### Returns - - -`\Automattic\WooCommerce\Blocks\StoreApi\Schemas\number` - -### Source - - -File: [StoreApi/Schemas/CartItemSchema.php](../src/StoreApi/Schemas/CartItemSchema.php) - ---- - -## woocommerce_store_api_item_quantity_step - - -Filters the quantity increment for a cart item in Store API. +### Description -```php -apply_filters( 'woocommerce_store_api_item_quantity_step', array $cart_item ) -``` +Filters the variation option name for custom option slugs.
### Parameters | Argument | Type | Description | | -------- | ---- | ----------- | -| $cart_item | array | Cart item array. | +| $quantity_limit | integer | Quantity limit which defaults to 99 unless sold individually. | +| $product | \WC_Product | Product instance. | ### Returns -`\Automattic\WooCommerce\Blocks\StoreApi\Schemas\number` +`integer` ### Source -File: [StoreApi/Schemas/CartItemSchema.php](../src/StoreApi/Schemas/CartItemSchema.php) + - [StoreApi/Utilities/QuantityLimits.php](../src/StoreApi/Utilities/QuantityLimits.php) --- -## woocommerce_store_api_product_quantity_limit +## woocommerce_store_api_product_quantity_{$value_type} -Filters the quantity limit for a product being added to the cart via the Store API. +Filters the quantity minimum for a cart item in Store API. This allows extensions to control the minimum qty of items already within the cart. ```php -apply_filters( 'woocommerce_store_api_product_quantity_limit', integer $quantity_limit, \WC_Product $product ) +apply_filters( 'woocommerce_store_api_product_quantity_{$value_type}', mixed $value, \WC_Product $product, array|null $cart_item ) ``` ### Description -Filters the variation option name for custom option slugs.
+The suffix of the hook will vary depending on the value being filtered. For example, minimum, maximum, multiple_of, editable.
### Parameters | Argument | Type | Description | | -------- | ---- | ----------- | -| $quantity_limit | integer | Quantity limit which defaults to 99 unless sold individually. | -| $product | \WC_Product | Product instance. | +| $value | mixed | The value being filtered. | +| $product | \WC_Product | The product object. | +| $cart_item | array, null | The cart item if the product exists in the cart, or null. | ### Returns -`integer` +`mixed` ### Source - - [StoreApi/Schemas/ProductSchema.php](../src/StoreApi/Schemas/ProductSchema.php) + - [StoreApi/Utilities/QuantityLimits.php](../src/StoreApi/Utilities/QuantityLimits.php) ---