From fb3d1876ce5a48c3332d38cbe57447684b9e8fc4 Mon Sep 17 00:00:00 2001 From: Patricia Hillebrandt Date: Fri, 24 Feb 2023 13:08:34 +0100 Subject: [PATCH] Bump woocommerce/woocommerce-sniffs from 0.1.0 to 0.1.3 (#8031) * Update WooCommerce Sniffs to version 0.1.3 * Add since versioning to all hooks to comply with the updated standards. * Add since tags for hooks. * Add the since tags to additional actions and filters * Update build hook documentation via > @woocommerce/block-library@9.2.0-dev prebuild:docs /Users/patriciahillebrandt/Woo/plugins/woocommerce-blocks > rimraf docs/extensibility/actions.md & rimraf docs/extensibility/filters.md > @woocommerce/block-library@9.2.0-dev build:docs /Users/patriciahillebrandt/Woo/plugins/woocommerce-blocks > ./vendor/bin/wp-hooks-generator --input=src --output=bin/hook-docs/data && node ./bin/hook-docs Scanning for files... Found 212 files. Parsing hooks... Done Let's create some docs! Generating Action Docs... Creating file docs/third-party-developers/extensibility/hooks/actions.md... Done! Generating Filter Docs... Creating file docs/third-party-developers/extensibility/hooks/filters.md... Done! > @woocommerce/block-library@9.2.0-dev postbuild:docs /Users/patriciahillebrandt/Woo/plugins/woocommerce-blocks > ./bin/add-doc-footer.sh * Add since tag for additional hooks. * build hook documentation * Update QuantityLimits filter_value docblock. * Add the @since tags to recently added hooks. * Add tag for the woocommerce_loop_add_to_cart_args filter. * Update hooks documentation --------- Co-authored-by: Niels Lange --- bin/hook-docs/data/actions.json | 261 +++++++++++++++++- bin/hook-docs/data/filters.json | 230 ++++++++++++++- composer.json | 2 +- composer.lock | 22 +- docs/README.md | 1 + .../contributing/css-build-system.md | 1 + .../contributing/folder-structure.md | 1 + .../contributing/getting-started.md | 1 + .../contributing/javascript-build-system.md | 1 + .../extensibility/README.md | 1 + .../checkout-block/available-filters.md | 1 + .../how-checkout-processes-an-order.md | 10 + .../payment-method-integration.md | 1 + .../extensibility/data-store/cart.md | 2 +- .../extensibility/data-store/checkout.md | 1 + .../extensibility/data-store/payment.md | 1 + .../extensibility/hooks/actions.md | 77 +++++- .../extensibility/hooks/filters.md | 115 +++++++- src/Assets/Api.php | 2 + src/Assets/AssetDataRegistry.php | 2 + src/BlockTypes/AbstractProductGrid.php | 4 + src/BlockTypes/AddToCartForm.php | 2 + src/BlockTypes/Cart.php | 6 + src/BlockTypes/Checkout.php | 6 + src/BlockTypes/ClassicTemplate.php | 38 ++- src/BlockTypes/MiniCart.php | 2 + src/BlockTypes/ProductButton.php | 13 +- src/BlockTypesController.php | 4 + src/Domain/Bootstrap.php | 16 +- src/Integrations/IntegrationRegistry.php | 2 + src/Payments/Integrations/PayPal.php | 2 + src/StoreApi/Authentication.php | 7 + src/StoreApi/README.md | 1 + src/StoreApi/Routes/V1/AbstractCartRoute.php | 11 + src/StoreApi/Routes/V1/CartAddItem.php | 2 + .../Routes/V1/CartSelectShippingRate.php | 2 + src/StoreApi/Routes/V1/CartUpdateCustomer.php | 2 + src/StoreApi/Routes/V1/Checkout.php | 16 ++ src/StoreApi/Schemas/V1/CartItemSchema.php | 4 + src/StoreApi/Utilities/CartController.php | 28 ++ src/StoreApi/Utilities/ProductQuery.php | 2 + src/StoreApi/Utilities/QuantityLimits.php | 4 + src/StoreApi/Utilities/RateLimits.php | 2 + src/StoreApi/docs/cart.md | 1 + src/Templates/BlockTemplatesCompatibility.php | 7 + .../emails/customer-new-account-blocks.php | 16 +- .../plain/customer-new-account-blocks.php | 7 + 47 files changed, 876 insertions(+), 64 deletions(-) diff --git a/bin/hook-docs/data/actions.json b/bin/hook-docs/data/actions.json index 73c441381bd..474aa4adcec 100644 --- a/bin/hook-docs/data/actions.json +++ b/bin/hook-docs/data/actions.json @@ -6,9 +6,14 @@ "file": "Domain/Bootstrap.php", "type": "action", "doc": { - "description": "", + "description": "Fires when a deprecated function is called.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "7.3.0" + } + ], "long_description_html": "" }, "args": 3 @@ -21,6 +26,10 @@ "description": "Fires when an item is added to the cart.", "long_description": "This hook fires when an item is added to the cart. This is triggered from the Store API in this context, but WooCommerce core add to cart events trigger the same hook.", "tags": [ + { + "name": "since", + "content": "2.5.0" + }, { "name": "internal", "content": "Matches action name in WooCommerce core." @@ -90,6 +99,10 @@ "name": "see", "content": "Outputs closing DIV for the content (priority 10)", "refers": "woocommerce_output_content_wrapper_end()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "

Called after rendering the main content for a product.

" @@ -108,6 +121,10 @@ "name": "see", "content": "Outputs closing DIV for the content (priority 10)", "refers": "woocommerce_output_content_wrapper_end()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "

Called after rendering the main content for a product.

" @@ -126,6 +143,10 @@ "name": "see", "content": "Renders pagination (priority 10)", "refers": "woocommerce_pagination()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "" @@ -140,6 +161,10 @@ "description": "Fires after a coupon has been applied to the cart.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.6.0" + }, { "name": "internal", "content": "Matches action name in WooCommerce core." @@ -174,6 +199,10 @@ "name": "see", "content": "Renders the product archive description (priority 10)", "refers": "woocommerce_product_archive_description()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "" @@ -202,6 +231,10 @@ "name": "see", "content": "Outputs schema markup (priority 30)", "refers": "WC_Structured_Data::generate_website_data()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "

Called before rendering the main content for a product.

" @@ -230,6 +263,10 @@ "name": "see", "content": "Outputs schema markup (priority 30)", "refers": "WC_Structured_Data::generate_website_data()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "

Called before rendering the main content for a product.

" @@ -258,6 +295,10 @@ "name": "see", "content": "Show form to control sort order (priority 30)", "refers": "woocommerce_catalog_ordering()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "" @@ -266,24 +307,34 @@ }, { "name": "woocommerce_blocks_cart_enqueue_data", - "file": "BlockTypes/Cart.php", + "file": "BlockTypes/MiniCart.php", "type": "action", "doc": { "description": "Fires after cart block data is registered.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "5.8.0" + } + ], "long_description_html": "" }, "args": 0 }, { "name": "woocommerce_blocks_cart_enqueue_data", - "file": "BlockTypes/MiniCart.php", + "file": "BlockTypes/Cart.php", "type": "action", "doc": { "description": "Fires after cart block data is registered.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "2.6.0" + } + ], "long_description_html": "" }, "args": 0 @@ -295,7 +346,12 @@ "doc": { "description": "Fires after checkout block data is registered.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "2.6.0" + } + ], "long_description_html": "" }, "args": 0 @@ -307,7 +363,12 @@ "doc": { "description": "Fires after cart block scripts are enqueued.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "2.6.0" + } + ], "long_description_html": "" }, "args": 0 @@ -319,7 +380,12 @@ "doc": { "description": "Fires before cart block scripts are enqueued.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "2.6.0" + } + ], "long_description_html": "" }, "args": 0 @@ -331,7 +397,12 @@ "doc": { "description": "Fires after checkout block scripts are enqueued.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "4.6.0" + } + ], "long_description_html": "" }, "args": 0 @@ -343,7 +414,12 @@ "doc": { "description": "Fires before checkout block scripts are enqueued.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "4.6.0" + } + ], "long_description_html": "" }, "args": 0 @@ -355,7 +431,12 @@ "doc": { "description": "Fires when the woocommerce blocks are loaded and ready to use.", "long_description": "This hook is intended to be used as a safe event hook for when the plugin has been loaded, and all dependency requirements have been met.\n To ensure blocks are initialized, you must use the `woocommerce_blocks_loaded` hook instead of the `plugins_loaded` hook. This is because the functions hooked into plugins_loaded on the same priority load in an inconsistent and unpredictable manner.", - "tags": [], + "tags": [ + { + "name": "since", + "content": "2.5.0" + } + ], "long_description_html": "

This hook is intended to be used as a safe event hook for when the plugin has been loaded, and all dependency requirements have been met.

To ensure blocks are initialized, you must use the woocommerce_blocks_loaded hook instead of the plugins_loaded hook. This is because the functions hooked into plugins_loaded on the same priority load in an inconsistent and unpredictable manner.

" }, "args": 0 @@ -368,6 +449,10 @@ "description": "Fires when the IntegrationRegistry is initialized.", "long_description": "Runs before integrations are initialized allowing new integration to be registered for use. This should be used as the primary hook for integrations to include their scripts, styles, and other code extending the blocks.", "tags": [ + { + "name": "since", + "content": "4.6.0" + }, { "name": "param", "content": "Instance of the IntegrationRegistry class which exposes the IntegrationRegistry::register() method.", @@ -389,6 +474,10 @@ "description": "Fires when cart items are being validated.", "long_description": "Allow 3rd parties to validate cart items. This is a legacy hook from Woo core. This filter will be deprecated because it encourages usage of wc_add_notice. For the API we need to capture notices and convert to wp errors instead.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "deprecated", "content": "" @@ -410,6 +499,10 @@ "description": "Fires after a customer account has been registered.", "long_description": "This hook fires after customer accounts are created and passes the customer data.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -455,6 +548,10 @@ "name": "see", "content": "Default no products found content (priority 10)", "refers": "wc_no_products_found()" + }, + { + "name": "since", + "content": "6.3.0" } ], "long_description_html": "" @@ -469,6 +566,10 @@ "description": "Fires before a customer account is registered.", "long_description": "This hook fires before customer accounts are created and passes the form data (username, email) and an array of errors.\n This could be used to add extra validation logic and append errors to the array.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -549,7 +650,12 @@ "doc": { "description": "Hook: woocommerce_shop_loop.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "6.3.0" + } + ], "long_description_html": "" }, "args": 0 @@ -562,6 +668,10 @@ "description": "Fires an action to validate the cart.", "long_description": "Functions hooking into this should add custom errors using the provided WP_Error instance.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "example", "content": "docs/examples/validate-cart.md" @@ -587,6 +697,48 @@ }, "args": 2 }, + { + "name": "woocommerce_store_api_cart_select_shipping_rate", + "file": "StoreApi/Routes/V1/CartSelectShippingRate.php", + "type": "action", + "doc": { + "description": "Fires an action after a shipping method has been chosen for package(s) via the Store API.", + "long_description": "This allows extensions to perform addition actions after a shipping method has been chosen, but before the cart totals are recalculated.", + "tags": [ + { + "name": "since", + "content": "9.0.0" + }, + { + "name": "param", + "content": "The sanitized ID of the package being updated. Null if all packages are being updated.", + "types": [ + "string", + "null" + ], + "variable": "$package_id" + }, + { + "name": "param", + "content": "The sanitized chosen rate ID for the package.", + "types": [ + "string" + ], + "variable": "$rate_id" + }, + { + "name": "param", + "content": "Full details about the request.", + "types": [ + "\\WP_REST_Request" + ], + "variable": "$request" + } + ], + "long_description_html": "

This allows extensions to perform addition actions after a shipping method has been chosen, but before the cart totals are recalculated.

" + }, + "args": 3 + }, { "name": "woocommerce_store_api_cart_update_customer_from_request", "file": "StoreApi/Routes/V1/CartUpdateCustomer.php", @@ -595,6 +747,10 @@ "description": "Fires when the Checkout Block/Store API updates a customer from the API request data.", "long_description": "", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "param", "content": "Customer object.", @@ -624,6 +780,10 @@ "description": "Fires when the order is synced with cart data from a cart route.", "long_description": "", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "param", "content": "Order object.", @@ -661,6 +821,10 @@ "description": "Fires before an order is processed by the Checkout Block/Store API.", "long_description": "This hook informs extensions that $order has completed processing and is ready for payment.\n This is similar to existing core hook woocommerce_checkout_order_processed. We're using a new action: - To keep the interface focused (only pass $order, not passing request data). - This also explicitly indicates these orders are from checkout block/StoreAPI.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "see", "content": "", @@ -691,6 +855,10 @@ "description": "Fires when the Checkout Block/Store API updates a customer from the API request data.", "long_description": "", "tags": [ + { + "name": "since", + "content": "8.2.0" + }, { "name": "param", "content": "Customer object.", @@ -720,6 +888,10 @@ "description": "Fires when the Checkout Block/Store API updates an order's from the API request data.", "long_description": "This hook gives extensions the chance to update orders based on the data in the request. This can be used in conjunction with the ExtendSchema class to post custom data and then process it.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "param", "content": "Order object.", @@ -749,6 +921,10 @@ "description": "Fires when the Checkout Block/Store API updates an order's meta data.", "long_description": "This hook gives extensions the chance to add or update meta data on the $order. Throwing an exception from a callback attached to this action will make the Checkout Block render in a warning state, effectively preventing checkout.\n This is similar to existing core hook woocommerce_checkout_update_order_meta. We're using a new action: - To keep the interface focused (only pass $order, not passing request data). - This also explicitly indicates these orders are from checkout block/StoreAPI.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "see", "content": "", @@ -772,9 +948,22 @@ "file": "StoreApi/Authentication.php", "type": "action", "doc": { - "description": "", + "description": "Fires when the rate limit is exceeded.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "8.9.0" + }, + { + "name": "param", + "content": "The IP address of the request.", + "types": [ + "string" + ], + "variable": "$ip_address" + } + ], "long_description_html": "" }, "args": 1 @@ -787,6 +976,10 @@ "description": "Fires during validation when adding an item to the cart via the Store API.", "long_description": "Fire action to validate add to cart. Functions hooking into this should throw an \\Exception to prevent add to cart from happening.", "tags": [ + { + "name": "since", + "content": "7.1.0" + }, { "name": "param", "content": "Product object being added to the cart.", @@ -816,6 +1009,10 @@ "description": "Fire action to validate add to cart. Functions hooking into this should throw an \\Exception to prevent add to cart from occurring.", "long_description": "", "tags": [ + { + "name": "since", + "content": "7.1.0" + }, { "name": "param", "content": "Product object being added to the cart.", @@ -836,6 +1033,40 @@ "long_description_html": "" }, "args": 2 + }, + { + "name": "woocommerce_{$product->get_type()}_add_to_cart", + "file": "BlockTypes/AddToCartForm.php", + "type": "action", + "doc": { + "description": "Trigger the single product add to cart action for each product type.", + "long_description": "", + "tags": [ + { + "name": "since", + "content": "9.7.0" + } + ], + "long_description_html": "" + }, + "args": 0 + }, + { + "name": "{$hook}", + "file": "Templates/BlockTemplatesCompatibility.php", + "type": "action", + "doc": { + "description": "Action to render the content of a hook.", + "long_description": "", + "tags": [ + { + "name": "since", + "content": "9.5.0" + } + ], + "long_description_html": "" + }, + "args": 0 } ] } \ No newline at end of file diff --git a/bin/hook-docs/data/filters.json b/bin/hook-docs/data/filters.json index 2c587ad3c2d..455beae53d0 100644 --- a/bin/hook-docs/data/filters.json +++ b/bin/hook-docs/data/filters.json @@ -9,6 +9,10 @@ "description": "Filters the list of allowed Block Names", "long_description": "This hook defines which block names should have block name and attribute data- attributes appended on render.", "tags": [ + { + "name": "since", + "content": "5.9.0" + }, { "name": "param", "content": "List of namespaces.", @@ -30,6 +34,10 @@ "description": "Filters the list of allowed block namespaces.", "long_description": "This hook defines which block namespaces should have block name and attribute `data-` attributes appended on render.", "tags": [ + { + "name": "since", + "content": "5.9.0" + }, { "name": "param", "content": "List of namespaces.", @@ -51,6 +59,10 @@ "description": "Filter to control what features are available for each payment gateway.", "long_description": "", "tags": [ + { + "name": "since", + "content": "4.4.0" + }, { "name": "example", "content": "docs/examples/payment-gateways-features-list.md" @@ -88,9 +100,22 @@ "file": "Domain/Bootstrap.php", "type": "filter", "doc": { - "description": "", + "description": "Filters whether to trigger an error for deprecated functions. (Same as WP core)", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "7.3.0" + }, + { + "name": "param", + "content": "Whether to trigger the error for deprecated functions. Default true.", + "types": [ + "bool" + ], + "variable": "$trigger" + } + ], "long_description_html": "" }, "args": 1 @@ -100,9 +125,22 @@ "file": "StoreApi/Routes/V1/AbstractCartRoute.php", "type": "filter", "doc": { - "description": "", + "description": "Filters the session expiration.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "8.7.0" + }, + { + "name": "param", + "content": "Expiration in seconds.", + "types": [ + "int" + ], + "variable": "$expiration" + } + ], "long_description_html": "" }, "args": 1 @@ -115,6 +153,10 @@ "description": "Filters the item being added to the cart.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.5.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -155,6 +197,10 @@ "description": "Filter cart item data for add to cart requests.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.5.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -211,6 +257,10 @@ "description": "Filter sold individually quantity for add to cart requests.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.5.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -275,6 +325,10 @@ "description": "Filters if an item being added to the cart passed validation checks.", "long_description": "Allow 3rd parties to validate if an item can be added to the cart. This is a legacy hook from Woo core. This filter will be deprecated because it encourages usage of wc_add_notice. For the API we need to capture notices and convert to exceptions instead.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "deprecated", "content": "" @@ -339,6 +393,10 @@ "description": "Filters if taxes should be removed from locations outside the store base location.", "long_description": "The woocommerce_adjust_non_base_location_prices filter can stop base taxes being taken off when dealing with out of base locations. e.g. If a product costs 10 including tax, all users will pay 10 regardless of location and taxes.", "tags": [ + { + "name": "since", + "content": "2.6.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -363,6 +421,18 @@ }, "args": 1 }, + { + "name": "woocommerce_apply_base_tax_for_local_pickup", + "file": "Shipping/ShippingController.php", + "type": "filter", + "doc": { + "description": "", + "long_description": "", + "tags": [], + "long_description_html": "" + }, + "args": 1 + }, { "name": "woocommerce_apply_individual_use_coupon", "file": "StoreApi/Utilities/CartController.php", @@ -371,6 +441,10 @@ "description": "Filter coupons to remove when applying an individual use coupon.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.6.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -419,6 +493,10 @@ "description": "Filters if a coupon can be applied alongside other individual use coupons.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.6.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -467,6 +545,31 @@ }, "args": 4 }, + { + "name": "woocommerce_blocks_hook_compatibility_additional_data", + "file": "Templates/BlockTemplatesCompatibility.php", + "type": "filter", + "doc": { + "description": "When extensions implement their equivalent blocks of the template hook functions, they can use this filter to register their old hooked data here, so in the blockified template, the old hooked functions can be removed in favor of the new blocks while keeping the old hooked functions working in classic templates.", + "long_description": "Accepts an array of hooked data. The array should be in the following format: [ [ hook => , function => , priority => , ], ... ] Where: - hook-name is the name of the hook that have the functions hooked to. - function-name is the hooked function name. - priority is the priority of the hooked function.", + "tags": [ + { + "name": "param", + "content": "Additional hooked data. Default to empty", + "types": [ + "array" + ], + "variable": "$data" + }, + { + "name": "since", + "content": "9.5.0" + } + ], + "long_description_html": "

Accepts an array of hooked data. The array should be in the following format: [ [ hook => , function => , priority => , ], ... ] Where:

  • hook-name is the name of the hook that have the functions hooked to.
  • function-name is the hooked function name.
  • priority is the priority of the hooked function.
" + }, + "args": 1 + }, { "name": "woocommerce_blocks_product_grid_is_cacheable", "file": "BlockTypes/AbstractProductGrid.php", @@ -497,6 +600,10 @@ "types": [ "array" ] + }, + { + "name": "since", + "content": "2.5.0" } ], "long_description_html": "" @@ -541,6 +648,10 @@ "types": [ "string" ] + }, + { + "name": "since", + "content": "2.2.0" } ], "long_description_html": "" @@ -555,6 +666,10 @@ "description": "Filters the list of script dependencies.", "long_description": "", "tags": [ + { + "name": "since", + "content": "3.0.0" + }, { "name": "param", "content": "The list of script dependencies.", @@ -591,6 +706,10 @@ "description": "Filters the entire cart contents when the cart changes.", "long_description": "", "tags": [ + { + "name": "since", + "content": "2.5.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -652,6 +771,10 @@ "description": "Filters cart item data.", "long_description": "Filters the variation option name for custom option slugs.", "tags": [ + { + "name": "since", + "content": "4.3.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -685,17 +808,47 @@ "args": 2 }, { - "name": "woocommerce_loop_add_to_cart_link", + "name": "woocommerce_loop_add_to_cart_args", "file": "BlockTypes/ProductButton.php", "type": "filter", "doc": { - "description": "", + "description": "Allow filtering of the add to cart button arguments.", "long_description": "", - "tags": [], + "tags": [ + { + "name": "since", + "content": "9.7.0" + } + ], "long_description_html": "" }, "args": 2 }, + { + "name": "woocommerce_loop_add_to_cart_link", + "file": "BlockTypes/ProductButton.php", + "type": "filter", + "doc": { + "description": "Filters the add to cart button class.", + "long_description": "", + "tags": [ + { + "name": "since", + "content": "8.7.0" + }, + { + "name": "param", + "content": "The class.", + "types": [ + "string" + ], + "variable": "$class" + } + ], + "long_description_html": "" + }, + "args": 3 + }, { "name": "woocommerce_new_customer_data", "file": "StoreApi/Routes/V1/Checkout.php", @@ -704,6 +857,10 @@ "description": "Filters customer data before a customer account is registered.", "long_description": "This hook filters customer data. It allows user data to be changed, for example, username, password, email, first name, last name, and role.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "param", "content": "An array of customer (user) data.", @@ -732,6 +889,10 @@ "description": "Filters registration errors before a customer account is registered.", "long_description": "This hook filters registration errors. This can be used to manipulate the array of errors before they are displayed.", "tags": [ + { + "name": "since", + "content": "7.2.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -780,6 +941,10 @@ "description": "Filters the array of shared settings.", "long_description": "Low level hook for registration of new data late in the cycle. This is deprecated. Instead, use the data api:\n ```php Automattic\\WooCommerce\\Blocks\\Package::container()->get( Automattic\\WooCommerce\\Blocks\\Assets\\AssetDataRegistry::class )->add( $key, $value ) ```", "tags": [ + { + "name": "since", + "content": "5.0.0" + }, { "name": "deprecated", "content": "" @@ -812,6 +977,10 @@ "description": "Filters the shipping package name.", "long_description": "", "tags": [ + { + "name": "since", + "content": "4.3.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." @@ -852,21 +1021,32 @@ }, "args": 3 }, + { + "name": "woocommerce_shipping_{$this->id}_is_available", + "file": "Shipping/PickupLocation.php", + "type": "filter", + "doc": { + "description": "", + "long_description": "", + "tags": [], + "long_description_html": "" + }, + "args": 3 + }, { "name": "woocommerce_show_page_title", "file": "BlockTypes/ClassicTemplate.php", "type": "filter", "doc": { - "description": "We need to load the scripts here because when using block templates wp_head() gets run after the block template. As a result we are trying to enqueue required scripts before we have even registered them.", - "long_description": "", + "description": "Hook: woocommerce_show_page_title", + "long_description": "Allows controlling the display of the page title.", "tags": [ { - "name": "see", - "content": "", - "refers": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5328#issuecomment-989013447" + "name": "since", + "content": "6.3.0" } ], - "long_description_html": "" + "long_description_html": "

Allows controlling the display of the page title.

" }, "args": 1 }, @@ -878,6 +1058,10 @@ "description": "Filters cart item data sent via the API before it is passed to the cart controller.", "long_description": "This hook filters cart items. It allows the request data to be changed, for example, quantity, or supplemental cart item data, before it is passed into CartController::add_to_cart and stored to session.\n CartController::add_to_cart only expects the keys id, quantity, variation, and cart_item_data, so other values may be ignored. CartController::add_to_cart (and core) do already have a filter hook called woocommerce_add_cart_item, but this does not have access to the original Store API request like this hook does.", "tags": [ + { + "name": "since", + "content": "8.8.0" + }, { "name": "param", "content": "An array of customer (user) data.", @@ -906,6 +1090,10 @@ "description": "Filters the Store API nonce check.", "long_description": "This can be used to disable the nonce check when testing API endpoints via a REST API client.", "tags": [ + { + "name": "since", + "content": "4.5.0" + }, { "name": "param", "content": "If true, nonce checks will be disabled.", @@ -934,6 +1122,10 @@ "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": "since", + "content": "6.8.0" + }, { "name": "param", "content": "Quantity limit which defaults to 9999 unless sold individually.", @@ -970,6 +1162,10 @@ "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": "since", + "content": "6.8.0" + }, { "name": "param", "content": "The value being filtered.", @@ -1029,6 +1225,10 @@ "types": [ "array" ] + }, + { + "name": "since", + "content": "8.9.0" } ], "long_description_html": "" @@ -1043,6 +1243,10 @@ "description": "Filters the variation option name.", "long_description": "Filters the variation option name for custom option slugs.", "tags": [ + { + "name": "since", + "content": "2.5.0" + }, { "name": "internal", "content": "Matches filter name in WooCommerce core." diff --git a/composer.json b/composer.json index 42ea82d9710..e23ae09788c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require-dev": { "wp-phpunit/wp-phpunit": "^6.0", - "woocommerce/woocommerce-sniffs": "0.1.0", + "woocommerce/woocommerce-sniffs": "0.1.3", "yoast/phpunit-polyfills": "^1.0", "mockery/mockery": "^1.4", "wp-hooks/generator": "^0.9.0" diff --git a/composer.lock b/composer.lock index de551048da8..480159dbde6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a68864122c290ca1c66be92a676bb3ce", + "content-hash": "82def4e81cefe980af89e11c20f2deda", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -2570,23 +2570,23 @@ }, { "name": "woocommerce/woocommerce-sniffs", - "version": "0.1.0", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-sniffs.git", - "reference": "b72b7dd2e70aa6aed16f80cdae5b1e6cce2e4c79" + "reference": "4576d54595614d689bc4436acff8baaece3c5bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/b72b7dd2e70aa6aed16f80cdae5b1e6cce2e4c79", - "reference": "b72b7dd2e70aa6aed16f80cdae5b1e6cce2e4c79", + "url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/4576d54595614d689bc4436acff8baaece3c5bb0", + "reference": "4576d54595614d689bc4436acff8baaece3c5bb0", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "0.7.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", "php": ">=7.0", - "phpcompatibility/phpcompatibility-wp": "2.1.0", - "wp-coding-standards/wpcs": "2.3.0" + "phpcompatibility/phpcompatibility-wp": "^2.1.0", + "wp-coding-standards/wpcs": "^2.3.0" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -2608,9 +2608,9 @@ ], "support": { "issues": "https://github.com/woocommerce/woocommerce-sniffs/issues", - "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/master" + "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/0.1.3" }, - "time": "2020-08-06T18:23:45+00:00" + "time": "2022-02-17T15:34:51+00:00" }, { "name": "wp-coding-standards/wpcs", @@ -2839,5 +2839,5 @@ "platform-overrides": { "php": "7.4.32" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.1.0" } diff --git a/docs/README.md b/docs/README.md index 2d8780bbcb2..05f7f15066a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -151,3 +151,4 @@ The following tutorials from [developer.woocommerce.com](https://developer.wooco 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/README.md) + diff --git a/docs/contributors/contributing/css-build-system.md b/docs/contributors/contributing/css-build-system.md index 4f4ed2d2bae..30103e6189a 100644 --- a/docs/contributors/contributing/css-build-system.md +++ b/docs/contributors/contributing/css-build-system.md @@ -34,3 +34,4 @@ Webpack config is split between several files, some relevant ones for the CSS bu 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/contributors/contributing/css-build-system.md) + diff --git a/docs/contributors/contributing/folder-structure.md b/docs/contributors/contributing/folder-structure.md index 1bf0bbdc0db..0e025b4b811 100644 --- a/docs/contributors/contributing/folder-structure.md +++ b/docs/contributors/contributing/folder-structure.md @@ -197,3 +197,4 @@ This file is inspired by the great work of @JustinyAhin and @gziolo in + diff --git a/docs/contributors/contributing/getting-started.md b/docs/contributors/contributing/getting-started.md index f0bfdc00ee1..f7ae043eb99 100644 --- a/docs/contributors/contributing/getting-started.md +++ b/docs/contributors/contributing/getting-started.md @@ -147,3 +147,4 @@ To find out more about how to run automated JavaScript tests, check out the docu 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/contributors/contributing/getting-started.md) + diff --git a/docs/contributors/contributing/javascript-build-system.md b/docs/contributors/contributing/javascript-build-system.md index d91e0d71ed0..193113a6be7 100644 --- a/docs/contributors/contributing/javascript-build-system.md +++ b/docs/contributors/contributing/javascript-build-system.md @@ -84,3 +84,4 @@ Webpack config is split between several files: 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/contributors/contributing/javascript-build-system.md) + diff --git a/docs/third-party-developers/extensibility/README.md b/docs/third-party-developers/extensibility/README.md index 1d203af6142..26e7520a988 100644 --- a/docs/third-party-developers/extensibility/README.md +++ b/docs/third-party-developers/extensibility/README.md @@ -56,3 +56,4 @@ In addition to the reference material below, [please see the `block-checkout` pa 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/README.md) + diff --git a/docs/third-party-developers/extensibility/checkout-block/available-filters.md b/docs/third-party-developers/extensibility/checkout-block/available-filters.md index 0e5093a80c2..bc7de68870d 100644 --- a/docs/third-party-developers/extensibility/checkout-block/available-filters.md +++ b/docs/third-party-developers/extensibility/checkout-block/available-filters.md @@ -266,3 +266,4 @@ The error will also be shown in your console. 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/checkout-block/available-filters.md) + diff --git a/docs/third-party-developers/extensibility/checkout-block/how-checkout-processes-an-order.md b/docs/third-party-developers/extensibility/checkout-block/how-checkout-processes-an-order.md index e1203e13b27..7aba8f5d4ac 100644 --- a/docs/third-party-developers/extensibility/checkout-block/how-checkout-processes-an-order.md +++ b/docs/third-party-developers/extensibility/checkout-block/how-checkout-processes-an-order.md @@ -136,3 +136,13 @@ The `checkPaymentMethodsCanPay()` [function](https://github.com/woocommerce/wooc - [Here](https://github.com/woocommerce/woocommerce-blocks/blob/4af2c0916a936369be8a4f0044683b90b3af4f0d/assets/js/data/cart/index.ts#L46-L57), once the cart loads, we want to be able to display express payment methods, so we need to validate them first. - [Here](https://github.com/woocommerce/woocommerce-blocks/blob/4af2c0916a936369be8a4f0044683b90b3af4f0d/assets/js/data/cart/index.ts#L42-L43), once the cart changes, we may want to enable/disable certain payment methods - [Here](https://github.com/woocommerce/woocommerce-blocks/blob/4af2c0916a936369be8a4f0044683b90b3af4f0d/assets/js/data/checkout/index.ts#L44-L49), once the checkout loads, we want to verify all registered payment methods + + +--- + +[We're hiring!](https://woocommerce.com/careers/) Come work with us! + +🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/checkout-block/how-checkout-processes-an-order.md) + + + diff --git a/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md b/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md index b0218add8e5..0a9b977c42b 100644 --- a/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md +++ b/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md @@ -265,3 +265,4 @@ As an example, you can see how the Stripe extension adds it's integration in thi 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md) + diff --git a/docs/third-party-developers/extensibility/data-store/cart.md b/docs/third-party-developers/extensibility/data-store/cart.md index 10aa74b4383..270d536cb4e 100644 --- a/docs/third-party-developers/extensibility/data-store/cart.md +++ b/docs/third-party-developers/extensibility/data-store/cart.md @@ -413,7 +413,7 @@ const isShippingRateBeingSelected = store.isShippingRateBeingSelected(); [We're hiring!](https://woocommerce.com/careers/) Come work with us! -🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/data-store/checkout.md) +🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/data-store/cart.md) diff --git a/docs/third-party-developers/extensibility/data-store/checkout.md b/docs/third-party-developers/extensibility/data-store/checkout.md index ac05a5e5d6a..c94a0de8d31 100644 --- a/docs/third-party-developers/extensibility/data-store/checkout.md +++ b/docs/third-party-developers/extensibility/data-store/checkout.md @@ -167,3 +167,4 @@ This is true when the total is being re-calculated for the order. There are nume 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/data-store/checkout.md) + diff --git a/docs/third-party-developers/extensibility/data-store/payment.md b/docs/third-party-developers/extensibility/data-store/payment.md index be2313a5ccb..0fafbacebb5 100644 --- a/docs/third-party-developers/extensibility/data-store/payment.md +++ b/docs/third-party-developers/extensibility/data-store/payment.md @@ -478,3 +478,4 @@ const expressPaymentMethodsInitialized = 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/third-party-developers/extensibility/data-store/payment.md) + diff --git a/docs/third-party-developers/extensibility/hooks/actions.md b/docs/third-party-developers/extensibility/hooks/actions.md index 21795d4c110..72c892fd6a5 100644 --- a/docs/third-party-developers/extensibility/hooks/actions.md +++ b/docs/third-party-developers/extensibility/hooks/actions.md @@ -30,6 +30,7 @@ - [woocommerce_rest_checkout_process_payment_with_context](#woocommerce_rest_checkout_process_payment_with_context) - [woocommerce_shop_loop](#woocommerce_shop_loop) - [woocommerce_store_api_cart_errors](#woocommerce_store_api_cart_errors) + - [woocommerce_store_api_cart_select_shipping_rate](#woocommerce_store_api_cart_select_shipping_rate) - [woocommerce_store_api_cart_update_customer_from_request](#woocommerce_store_api_cart_update_customer_from_request) - [woocommerce_store_api_cart_update_order_from_request](#woocommerce_store_api_cart_update_order_from_request) - [woocommerce_store_api_checkout_order_processed](#woocommerce_store_api_checkout_order_processed) @@ -39,13 +40,15 @@ - [woocommerce_store_api_rate_limit_exceeded](#woocommerce_store_api_rate_limit_exceeded) - [woocommerce_store_api_validate_add_to_cart](#woocommerce_store_api_validate_add_to_cart) - [woocommerce_store_api_validate_cart_item](#woocommerce_store_api_validate_cart_item) + - [woocommerce_{$product->get_type()}_add_to_cart](#woocommerce_-product--get_type-_add_to_cart) + - [{$hook}](#-hook) --- ## deprecated_function_run - +Fires when a deprecated function is called. ```php do_action( 'deprecated_function_run' ) @@ -249,8 +252,8 @@ do_action( 'woocommerce_blocks_cart_enqueue_data' ) ### Source - - [BlockTypes/Cart.php](../../../../src/BlockTypes/Cart.php) - [BlockTypes/MiniCart.php](../../../../src/BlockTypes/MiniCart.php) + - [BlockTypes/Cart.php](../../../../src/BlockTypes/Cart.php) --- @@ -578,6 +581,34 @@ add_action( 'woocommerce_store_api_cart_errors', 'my_function_callback', 10 ); --- +## woocommerce_store_api_cart_select_shipping_rate + + +Fires an action after a shipping method has been chosen for package(s) via the Store API. + +```php +do_action( 'woocommerce_store_api_cart_select_shipping_rate', string|null $package_id, string $rate_id, \WP_REST_Request $request ) +``` + +### Description + +

This allows extensions to perform addition actions after a shipping method has been chosen, but before the cart totals are recalculated.

+ +### Parameters + +| Argument | Type | Description | +| -------- | ---- | ----------- | +| $package_id | string, null | The sanitized ID of the package being updated. Null if all packages are being updated. | +| $rate_id | string | The sanitized chosen rate ID for the package. | +| $request | \WP_REST_Request | Full details about the request. | + +### Source + + + - [StoreApi/Routes/V1/CartSelectShippingRate.php](../../../../src/StoreApi/Routes/V1/CartSelectShippingRate.php) + +--- + ## woocommerce_store_api_cart_update_customer_from_request @@ -755,12 +786,18 @@ do_action( 'woocommerce_store_api_checkout_update_order_meta', \WC_Order $order ## woocommerce_store_api_rate_limit_exceeded - +Fires when the rate limit is exceeded. ```php -do_action( 'woocommerce_store_api_rate_limit_exceeded' ) +do_action( 'woocommerce_store_api_rate_limit_exceeded', string $ip_address ) ``` +### Parameters + +| Argument | Type | Description | +| -------- | ---- | ----------- | +| $ip_address | string | The IP address of the request. | + ### Source @@ -816,6 +853,38 @@ do_action( 'woocommerce_store_api_validate_cart_item', \WC_Product $product, arr - [StoreApi/Utilities/CartController.php](../../../../src/StoreApi/Utilities/CartController.php) +--- + +## woocommerce_{$product->get_type()}_add_to_cart + + +Trigger the single product add to cart action for each product type. + +```php +do_action( 'woocommerce_{$product->get_type()}_add_to_cart' ) +``` + +### Source + + + - [BlockTypes/AddToCartForm.php](../../../../src/BlockTypes/AddToCartForm.php) + +--- + +## {$hook} + + +Action to render the content of a hook. + +```php +do_action( '{$hook}' ) +``` + +### Source + + + - [Templates/BlockTemplatesCompatibility.php](../../../../src/Templates/BlockTemplatesCompatibility.php) + --- diff --git a/docs/third-party-developers/extensibility/hooks/filters.md b/docs/third-party-developers/extensibility/hooks/filters.md index d6dec58c101..3f36185aaeb 100644 --- a/docs/third-party-developers/extensibility/hooks/filters.md +++ b/docs/third-party-developers/extensibility/hooks/filters.md @@ -17,19 +17,23 @@ - [woocommerce_add_to_cart_sold_individually_quantity](#woocommerce_add_to_cart_sold_individually_quantity) - [woocommerce_add_to_cart_validation](#-woocommerce_add_to_cart_validation) - [woocommerce_adjust_non_base_location_prices](#woocommerce_adjust_non_base_location_prices) + - [woocommerce_apply_base_tax_for_local_pickup](#woocommerce_apply_base_tax_for_local_pickup) - [woocommerce_apply_individual_use_coupon](#woocommerce_apply_individual_use_coupon) - [woocommerce_apply_with_individual_use_coupon](#woocommerce_apply_with_individual_use_coupon) + - [woocommerce_blocks_hook_compatibility_additional_data](#woocommerce_blocks_hook_compatibility_additional_data) - [woocommerce_blocks_product_grid_is_cacheable](#woocommerce_blocks_product_grid_is_cacheable) - [woocommerce_blocks_product_grid_item_html](#woocommerce_blocks_product_grid_item_html) - [woocommerce_blocks_register_script_dependencies](#woocommerce_blocks_register_script_dependencies) - [woocommerce_cart_contents_changed](#woocommerce_cart_contents_changed) - [woocommerce_ga_disable_tracking](#woocommerce_ga_disable_tracking) - [woocommerce_get_item_data](#woocommerce_get_item_data) + - [woocommerce_loop_add_to_cart_args](#woocommerce_loop_add_to_cart_args) - [woocommerce_loop_add_to_cart_link](#woocommerce_loop_add_to_cart_link) - [woocommerce_new_customer_data](#woocommerce_new_customer_data) - [woocommerce_registration_errors](#woocommerce_registration_errors) - [woocommerce_shared_settings](#-woocommerce_shared_settings) - [woocommerce_shipping_package_name](#woocommerce_shipping_package_name) + - [woocommerce_shipping_{$this->id}_is_available](#woocommerce_shipping_-this--id-_is_available) - [woocommerce_show_page_title](#woocommerce_show_page_title) - [woocommerce_store_api_add_to_cart_data](#woocommerce_store_api_add_to_cart_data) - [woocommerce_store_api_disable_nonce_check](#woocommerce_store_api_disable_nonce_check) @@ -141,12 +145,18 @@ add_filter( '__experimental_woocommerce_blocks_payment_gateway_features_list', ' ## deprecated_function_trigger_error - +Filters whether to trigger an error for deprecated functions. (Same as WP core) ```php -apply_filters( 'deprecated_function_trigger_error' ) +apply_filters( 'deprecated_function_trigger_error', bool $trigger ) ``` +### Parameters + +| Argument | Type | Description | +| -------- | ---- | ----------- | +| $trigger | bool | Whether to trigger the error for deprecated functions. Default true. | + ### Source @@ -157,12 +167,18 @@ apply_filters( 'deprecated_function_trigger_error' ) ## wc_session_expiration - +Filters the session expiration. ```php -apply_filters( 'wc_session_expiration' ) +apply_filters( 'wc_session_expiration', int $expiration ) ``` +### Parameters + +| Argument | Type | Description | +| -------- | ---- | ----------- | +| $expiration | int | Expiration in seconds. | + ### Source @@ -340,6 +356,22 @@ apply_filters( 'woocommerce_adjust_non_base_location_prices', boolean $adjust_no --- +## woocommerce_apply_base_tax_for_local_pickup + + + + +```php +apply_filters( 'woocommerce_apply_base_tax_for_local_pickup' ) +``` + +### Source + + + - [Shipping/ShippingController.php](../../../../src/Shipping/ShippingController.php) + +--- + ## woocommerce_apply_individual_use_coupon @@ -405,6 +437,32 @@ apply_filters( 'woocommerce_apply_with_individual_use_coupon', boolean $apply_wi --- +## woocommerce_blocks_hook_compatibility_additional_data + + +When extensions implement their equivalent blocks of the template hook functions, they can use this filter to register their old hooked data here, so in the blockified template, the old hooked functions can be removed in favor of the new blocks while keeping the old hooked functions working in classic templates. + +```php +apply_filters( 'woocommerce_blocks_hook_compatibility_additional_data', array $data ) +``` + +### Description + +

Accepts an array of hooked data. The array should be in the following format: [ [ hook => , function => , priority => , ], ... ] Where:

  • hook-name is the name of the hook that have the functions hooked to.
  • function-name is the hooked function name.
  • priority is the priority of the hooked function.
+ +### Parameters + +| Argument | Type | Description | +| -------- | ---- | ----------- | +| $data | array | Additional hooked data. Default to empty | + +### Source + + + - [Templates/BlockTemplatesCompatibility.php](../../../../src/Templates/BlockTemplatesCompatibility.php) + +--- + ## woocommerce_blocks_product_grid_is_cacheable @@ -580,15 +638,37 @@ apply_filters( 'woocommerce_get_item_data', array $item_data, array $cart_item ) --- -## woocommerce_loop_add_to_cart_link +## woocommerce_loop_add_to_cart_args + + +Allow filtering of the add to cart button arguments. + +```php +apply_filters( 'woocommerce_loop_add_to_cart_args' ) +``` + +### Source + + + - [BlockTypes/ProductButton.php](../../../../src/BlockTypes/ProductButton.php) +--- +## woocommerce_loop_add_to_cart_link +Filters the add to cart button class. + ```php -apply_filters( 'woocommerce_loop_add_to_cart_link' ) +apply_filters( 'woocommerce_loop_add_to_cart_link', string $class ) ``` +### Parameters + +| Argument | Type | Description | +| -------- | ---- | ----------- | +| $class | string | The class. | + ### Source @@ -729,19 +809,34 @@ apply_filters( 'woocommerce_shipping_package_name', string $shipping_package_nam --- +## woocommerce_shipping_{$this->id}_is_available + + + + +```php +apply_filters( 'woocommerce_shipping_{$this->id}_is_available' ) +``` + +### Source + + + - [Shipping/PickupLocation.php](../../../../src/Shipping/PickupLocation.php) + +--- + ## woocommerce_show_page_title -We need to load the scripts here because when using block templates wp_head() gets run after the block template. As a result we are trying to enqueue required scripts before we have even registered them. +Hook: woocommerce_show_page_title ```php apply_filters( 'woocommerce_show_page_title' ) ``` -### See - +### Description - - https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5328#issuecomment-989013447 +

Allows controlling the display of the page title.

### Source diff --git a/src/Assets/Api.php b/src/Assets/Api.php index 08dc872095e..3e3772fc4f0 100644 --- a/src/Assets/Api.php +++ b/src/Assets/Api.php @@ -150,6 +150,8 @@ function() use ( $handle ) { /** * Filters the list of script dependencies. * + * @since 3.0.0 + * * @param array $dependencies The list of script dependencies. * @param string $handle The script's handle. * @return array diff --git a/src/Assets/AssetDataRegistry.php b/src/Assets/AssetDataRegistry.php index 4c69410e999..0b87327c030 100644 --- a/src/Assets/AssetDataRegistry.php +++ b/src/Assets/AssetDataRegistry.php @@ -229,6 +229,8 @@ protected function initialize_core_data() { * Automattic\WooCommerce\Blocks\Package::container()->get( Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry::class )->add( $key, $value ) * ``` * + * @since 5.0.0 + * * @deprecated * @param array $data Settings data. * @return array diff --git a/src/BlockTypes/AbstractProductGrid.php b/src/BlockTypes/AbstractProductGrid.php index 2f6034532c4..8fe0641ac0b 100644 --- a/src/BlockTypes/AbstractProductGrid.php +++ b/src/BlockTypes/AbstractProductGrid.php @@ -348,6 +348,8 @@ protected function get_products() { * @param boolean $is_cacheable The list of script dependencies. * @param array $query_args Query args for the products query passed to BlocksWpQuery. * @return array True to enable cache, false to disable cache. + * + * @since 2.5.0 */ $is_cacheable = (bool) apply_filters( 'woocommerce_blocks_product_grid_is_cacheable', true, $this->query_args ); $transient_version = \WC_Cache_Helper::get_transient_version( 'product_query' ); @@ -504,6 +506,8 @@ protected function render_product( $product ) { * @param array $data Product data passed to the template. * @param \WC_Product $product Product object. * @return string Updated product grid item HTML. + * + * @since 2.2.0 */ return apply_filters( 'woocommerce_blocks_product_grid_item_html', diff --git a/src/BlockTypes/AddToCartForm.php b/src/BlockTypes/AddToCartForm.php index bf45693b1bf..fd3041c1e42 100644 --- a/src/BlockTypes/AddToCartForm.php +++ b/src/BlockTypes/AddToCartForm.php @@ -32,6 +32,8 @@ protected function render( $attributes, $content, $block ) { global $product; /** * Trigger the single product add to cart action for each product type. + * + * @since 9.7.0 */ do_action( 'woocommerce_' . $product->get_type() . '_add_to_cart' ); } diff --git a/src/BlockTypes/Cart.php b/src/BlockTypes/Cart.php index 48f0672d664..1888272f32b 100644 --- a/src/BlockTypes/Cart.php +++ b/src/BlockTypes/Cart.php @@ -64,11 +64,15 @@ protected function get_block_type_script( $key = null ) { protected function enqueue_assets( array $attributes ) { /** * Fires before cart block scripts are enqueued. + * + * @since 2.6.0 */ do_action( 'woocommerce_blocks_enqueue_cart_block_scripts_before' ); parent::enqueue_assets( $attributes ); /** * Fires after cart block scripts are enqueued. + * + * @since 2.6.0 */ do_action( 'woocommerce_blocks_enqueue_cart_block_scripts_after' ); } @@ -207,6 +211,8 @@ function() { /** * Fires after cart block data is registered. + * + * @since 2.6.0 */ do_action( 'woocommerce_blocks_cart_enqueue_data' ); } diff --git a/src/BlockTypes/Checkout.php b/src/BlockTypes/Checkout.php index e93a0544424..0609db2bb65 100644 --- a/src/BlockTypes/Checkout.php +++ b/src/BlockTypes/Checkout.php @@ -62,11 +62,15 @@ protected function get_block_type_script( $key = null ) { protected function enqueue_assets( array $attributes ) { /** * Fires before checkout block scripts are enqueued. + * + * @since 4.6.0 */ do_action( 'woocommerce_blocks_enqueue_checkout_block_scripts_before' ); parent::enqueue_assets( $attributes ); /** * Fires after checkout block scripts are enqueued. + * + * @since 4.6.0 */ do_action( 'woocommerce_blocks_enqueue_checkout_block_scripts_after' ); } @@ -338,6 +342,8 @@ function( $acc, $method ) { /** * Fires after checkout block data is registered. + * + * @since 2.6.0 */ do_action( 'woocommerce_blocks_checkout_enqueue_data' ); } diff --git a/src/BlockTypes/ClassicTemplate.php b/src/BlockTypes/ClassicTemplate.php index 616ea349d9b..46b9b6b1b6c 100644 --- a/src/BlockTypes/ClassicTemplate.php +++ b/src/BlockTypes/ClassicTemplate.php @@ -106,6 +106,8 @@ protected function render_single_product() { * @see woocommerce_output_content_wrapper() Outputs opening DIV for the content (priority 10) * @see woocommerce_breadcrumb() Outputs breadcrumb trail to the current product (priority 20) * @see WC_Structured_Data::generate_website_data() Outputs schema markup (priority 30) + * + * @since 6.3.0 */ do_action( 'woocommerce_before_main_content' ); @@ -122,6 +124,8 @@ protected function render_single_product() { * Called after rendering the main content for a product. * * @see woocommerce_output_content_wrapper_end() Outputs closing DIV for the content (priority 10) + * + * @since 6.3.0 */ do_action( 'woocommerce_after_main_content' ); @@ -146,21 +150,37 @@ protected function render_archive_product() { * @see woocommerce_output_content_wrapper() Outputs opening DIV for the content (priority 10) * @see woocommerce_breadcrumb() Outputs breadcrumb trail to the current product (priority 20) * @see WC_Structured_Data::generate_website_data() Outputs schema markup (priority 30) + * + * @since 6.3.0 */ do_action( 'woocommerce_before_main_content' ); ?>
- -

- - +

+ +

+ @@ -174,6 +194,8 @@ protected function render_archive_product() { * @see woocommerce_output_all_notices() Render error notices (priority 10) * @see woocommerce_result_count() Show number of results found (priority 20) * @see woocommerce_catalog_ordering() Show form to control sort order (priority 30) + * + * @since 6.3.0 */ do_action( 'woocommerce_before_shop_loop' ); @@ -185,6 +207,8 @@ protected function render_archive_product() { /** * Hook: woocommerce_shop_loop. + * + * @since 6.3.0 */ do_action( 'woocommerce_shop_loop' ); @@ -198,6 +222,8 @@ protected function render_archive_product() { * Hook: woocommerce_after_shop_loop. * * @see woocommerce_pagination() Renders pagination (priority 10) + * + * @since 6.3.0 */ do_action( 'woocommerce_after_shop_loop' ); } else { @@ -205,6 +231,8 @@ protected function render_archive_product() { * Hook: woocommerce_no_products_found. * * @see wc_no_products_found() Default no products found content (priority 10) + * + * @since 6.3.0 */ do_action( 'woocommerce_no_products_found' ); } @@ -215,6 +243,8 @@ protected function render_archive_product() { * Called after rendering the main content for a product. * * @see woocommerce_output_content_wrapper_end() Outputs closing DIV for the content (priority 10) + * + * @since 6.3.0 */ do_action( 'woocommerce_after_main_content' ); diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 9957caa2c82..75609a767b8 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -228,6 +228,8 @@ protected function enqueue_data( array $attributes = [] ) { /** * Fires after cart block data is registered. + * + * @since 5.8.0 */ do_action( 'woocommerce_blocks_cart_enqueue_data' ); } diff --git a/src/BlockTypes/ProductButton.php b/src/BlockTypes/ProductButton.php index 61c44ff6bc0..edb350d4413 100644 --- a/src/BlockTypes/ProductButton.php +++ b/src/BlockTypes/ProductButton.php @@ -101,7 +101,11 @@ protected function render( $attributes, $content, $block ) { ) ) ); - + /** + * Allow filtering of the add to cart button arguments. + * + * @since 9.7.0 + */ $args = apply_filters( 'woocommerce_loop_add_to_cart_args', array( @@ -120,6 +124,13 @@ protected function render( $attributes, $content, $block ) { $args['attributes']['aria-label'] = wp_strip_all_tags( $args['attributes']['aria-label'] ); } + /** + * Filters the add to cart button class. + * + * @since 8.7.0 + * + * @param string $class The class. + */ return apply_filters( 'woocommerce_loop_add_to_cart_link', sprintf( diff --git a/src/BlockTypesController.php b/src/BlockTypesController.php index 3aceae34083..2b46c98831e 100644 --- a/src/BlockTypesController.php +++ b/src/BlockTypesController.php @@ -82,6 +82,8 @@ public function add_data_attributes( $content, $block ) { * * This hook defines which block namespaces should have block name and attribute `data-` attributes appended on render. * + * @since 5.9.0 + * * @param array $allowed_namespaces List of namespaces. */ $allowed_namespaces = array_merge( [ 'woocommerce', 'woocommerce-checkout' ], (array) apply_filters( '__experimental_woocommerce_blocks_add_data_attributes_to_namespace', [] ) ); @@ -91,6 +93,8 @@ public function add_data_attributes( $content, $block ) { * * This hook defines which block names should have block name and attribute data- attributes appended on render. * + * @since 5.9.0 + * * @param array $allowed_namespaces List of namespaces. */ $allowed_blocks = (array) apply_filters( '__experimental_woocommerce_blocks_add_data_attributes_to_block', [] ); diff --git a/src/Domain/Bootstrap.php b/src/Domain/Bootstrap.php index c42d39028a2..a9ab1c73d58 100644 --- a/src/Domain/Bootstrap.php +++ b/src/Domain/Bootstrap.php @@ -80,6 +80,8 @@ public function __construct( Container $container ) { * To ensure blocks are initialized, you must use the `woocommerce_blocks_loaded` * hook instead of the `plugins_loaded` hook. This is because the functions * hooked into plugins_loaded on the same priority load in an inconsistent and unpredictable manner. + * + * @since 2.5.0 */ do_action( 'woocommerce_blocks_loaded' ); } @@ -386,7 +388,11 @@ protected function deprecated_dependency( $function, $version, $replacement = '' $function, $version ); - + /** + * Fires when a deprecated function is called. + * + * @since 7.3.0 + */ do_action( 'deprecated_function_run', $function, $replacement, $version ); $log_error = false; @@ -401,7 +407,13 @@ protected function deprecated_dependency( $function, $version, $replacement = '' $log_error = true; } - // Apply same filter as WP core. + /** + * Filters whether to trigger an error for deprecated functions. (Same as WP core) + * + * @since 7.3.0 + * + * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. + */ if ( ! apply_filters( 'deprecated_function_trigger_error', true ) ) { $log_error = true; } diff --git a/src/Integrations/IntegrationRegistry.php b/src/Integrations/IntegrationRegistry.php index 0d0d6e480a4..edbcdc2886d 100644 --- a/src/Integrations/IntegrationRegistry.php +++ b/src/Integrations/IntegrationRegistry.php @@ -43,6 +43,8 @@ public function initialize( $registry_identifier = '' ) { * used as the primary hook for integrations to include their scripts, styles, and other code extending the * blocks. * + * @since 4.6.0 + * * @param IntegrationRegistry $this Instance of the IntegrationRegistry class which exposes the IntegrationRegistry::register() method. */ do_action( 'woocommerce_blocks_' . $this->registry_identifier . '_registration', $this ); diff --git a/src/Payments/Integrations/PayPal.php b/src/Payments/Integrations/PayPal.php index 81e1205bd33..6becf7f81f3 100644 --- a/src/Payments/Integrations/PayPal.php +++ b/src/Payments/Integrations/PayPal.php @@ -87,6 +87,8 @@ public function get_supported_features() { /** * Filter to control what features are available for each payment gateway. * + * @since 4.4.0 + * * @example See docs/examples/payment-gateways-features-list.md * * @param array $features List of supported features. diff --git a/src/StoreApi/Authentication.php b/src/StoreApi/Authentication.php index 09159e0ef16..04cb63b5fb2 100644 --- a/src/StoreApi/Authentication.php +++ b/src/StoreApi/Authentication.php @@ -77,6 +77,13 @@ protected function apply_rate_limiting( $result ) { $server->send_header( 'RateLimit-Reset', time() + $retry ); $ip_address = $ip_address ?? self::get_ip_address( $rate_limiting_options->proxy_support ); + /** + * Fires when the rate limit is exceeded. + * + * @since 8.9.0 + * + * @param string $ip_address The IP address of the request. + */ do_action( 'woocommerce_store_api_rate_limit_exceeded', $ip_address ); return new \WP_Error( diff --git a/src/StoreApi/README.md b/src/StoreApi/README.md index b7e36fb2940..456822c00ea 100644 --- a/src/StoreApi/README.md +++ b/src/StoreApi/README.md @@ -172,3 +172,4 @@ If you're looking to add _new routes and endpoints_, rather than extending the S 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./src/StoreApi/README.md) + diff --git a/src/StoreApi/Routes/V1/AbstractCartRoute.php b/src/StoreApi/Routes/V1/AbstractCartRoute.php index 5a9e61060a5..7d3f43405ac 100644 --- a/src/StoreApi/Routes/V1/AbstractCartRoute.php +++ b/src/StoreApi/Routes/V1/AbstractCartRoute.php @@ -200,6 +200,13 @@ protected function get_cart_token_secret() { * @return int */ protected function get_cart_token_expiration() { + /** + * Filters the session expiration. + * + * @since 8.7.0 + * + * @param int $expiration Expiration in seconds. + */ return time() + intval( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) ); } @@ -240,6 +247,8 @@ protected function cart_updated( \WP_REST_Request $request ) { /** * Fires when the order is synced with cart data from a cart route. * + * @since 7.2.0 + * * @param \WC_Order $draft_order Order object. * @param \WC_Customer $customer Customer object. * @param \WP_REST_Request $request Full details about the request. @@ -276,6 +285,8 @@ protected function check_nonce( \WP_REST_Request $request ) { * * This can be used to disable the nonce check when testing API endpoints via a REST API client. * + * @since 4.5.0 + * * @param boolean $disable_nonce_check If true, nonce checks will be disabled. * * @return boolean diff --git a/src/StoreApi/Routes/V1/CartAddItem.php b/src/StoreApi/Routes/V1/CartAddItem.php index 2173ee82c48..12de2e6aade 100644 --- a/src/StoreApi/Routes/V1/CartAddItem.php +++ b/src/StoreApi/Routes/V1/CartAddItem.php @@ -101,6 +101,8 @@ protected function get_route_post_response( \WP_REST_Request $request ) { * may be ignored. CartController::add_to_cart (and core) do already have a filter hook called * woocommerce_add_cart_item, but this does not have access to the original Store API request like this hook does. * + * @since 8.8.0 + * * @param array $customer_data An array of customer (user) data. * @return array */ diff --git a/src/StoreApi/Routes/V1/CartSelectShippingRate.php b/src/StoreApi/Routes/V1/CartSelectShippingRate.php index 97c3b070705..0dcac56c2e1 100644 --- a/src/StoreApi/Routes/V1/CartSelectShippingRate.php +++ b/src/StoreApi/Routes/V1/CartSelectShippingRate.php @@ -90,6 +90,8 @@ protected function get_route_post_response( \WP_REST_Request $request ) { * This allows extensions to perform addition actions after a shipping method has been chosen, but before the * cart totals are recalculated. * + * @since 9.0.0 + * * @param string|null $package_id The sanitized ID of the package being updated. Null if all packages are being updated. * @param string $rate_id The sanitized chosen rate ID for the package. * @param \WP_REST_Request $request Full details about the request. diff --git a/src/StoreApi/Routes/V1/CartUpdateCustomer.php b/src/StoreApi/Routes/V1/CartUpdateCustomer.php index 264e3da6cc2..bceeaff7e32 100644 --- a/src/StoreApi/Routes/V1/CartUpdateCustomer.php +++ b/src/StoreApi/Routes/V1/CartUpdateCustomer.php @@ -197,6 +197,8 @@ protected function get_route_post_response( \WP_REST_Request $request ) { /** * Fires when the Checkout Block/Store API updates a customer from the API request data. * + * @since 7.2.0 + * * @param \WC_Customer $customer Customer object. * @param \WP_REST_Request $request Full details about the request. */ diff --git a/src/StoreApi/Routes/V1/Checkout.php b/src/StoreApi/Routes/V1/Checkout.php index 5a5112edf84..8fbff10a167 100644 --- a/src/StoreApi/Routes/V1/Checkout.php +++ b/src/StoreApi/Routes/V1/Checkout.php @@ -218,6 +218,8 @@ protected function get_route_post_response( \WP_REST_Request $request ) { * - To keep the interface focused (only pass $order, not passing request data). * - This also explicitly indicates these orders are from checkout block/StoreAPI. * + * @since 7.2.0 + * * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3238 * @example See docs/examples/checkout-order-processed.md @@ -346,6 +348,8 @@ private function create_or_update_draft_order( \WP_REST_Request $request ) { * - To keep the interface focused (only pass $order, not passing request data). * - This also explicitly indicates these orders are from checkout block/StoreAPI. * + * @since 7.2.0 + * * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3686 * * @param \WC_Order $order Order object. @@ -414,6 +418,8 @@ private function update_customer_from_request( \WP_REST_Request $request ) { /** * Fires when the Checkout Block/Store API updates a customer from the API request data. * + * @since 8.2.0 + * * @param \WC_Customer $customer Customer object. * @param \WP_REST_Request $request Full details about the request. */ @@ -459,6 +465,8 @@ private function update_order_from_request( \WP_REST_Request $request ) { * This hook gives extensions the chance to update orders based on the data in the request. This can be used in * conjunction with the ExtendSchema class to post custom data and then process it. * + * @since 7.2.0 + * * @param \WC_Order $order Order object. * @param \WP_REST_Request $request Full details about the request. */ @@ -711,6 +719,8 @@ private function create_customer_account( $user_email, $first_name, $last_name ) * * This could be used to add extra validation logic and append errors to the array. * + * @since 7.2.0 + * * @internal Matches filter name in WooCommerce core. * * @param string $username Customer username. @@ -725,6 +735,8 @@ private function create_customer_account( $user_email, $first_name, $last_name ) * This hook filters registration errors. This can be used to manipulate the array of errors before * they are displayed. * + * @since 7.2.0 + * * @internal Matches filter name in WooCommerce core. * * @param \WP_Error $errors Error object. @@ -744,6 +756,8 @@ private function create_customer_account( $user_email, $first_name, $last_name ) * This hook filters customer data. It allows user data to be changed, for example, username, password, email, * first name, last name, and role. * + * @since 7.2.0 + * * @param array $customer_data An array of customer (user) data. * @return array */ @@ -774,6 +788,8 @@ private function create_customer_account( $user_email, $first_name, $last_name ) * * This hook fires after customer accounts are created and passes the customer data. * + * @since 7.2.0 + * * @internal Matches filter name in WooCommerce core. * * @param integer $customer_id New customer (user) ID. diff --git a/src/StoreApi/Schemas/V1/CartItemSchema.php b/src/StoreApi/Schemas/V1/CartItemSchema.php index d61650b5ca7..634210c506a 100644 --- a/src/StoreApi/Schemas/V1/CartItemSchema.php +++ b/src/StoreApi/Schemas/V1/CartItemSchema.php @@ -419,6 +419,8 @@ protected function format_variation_data( $variation_data, $product ) { * * Filters the variation option name for custom option slugs. * + * @since 2.5.0 + * * @internal Matches filter name in WooCommerce core. * * @param string $value The name to display. @@ -452,6 +454,8 @@ protected function get_item_data( $cart_item ) { * * Filters the variation option name for custom option slugs. * + * @since 4.3.0 + * * @internal Matches filter name in WooCommerce core. * * @param array $item_data Cart item data. Empty by default. diff --git a/src/StoreApi/Utilities/CartController.php b/src/StoreApi/Utilities/CartController.php index 1b1e674cce3..ec0cccde5a5 100644 --- a/src/StoreApi/Utilities/CartController.php +++ b/src/StoreApi/Utilities/CartController.php @@ -108,6 +108,8 @@ public function add_to_cart( $request ) { /** * Filters the item being added to the cart. * + * @since 2.5.0 + * * @internal Matches filter name in WooCommerce core. * * @param array $cart_item_data Array of cart item data being added to the cart. @@ -134,6 +136,8 @@ public function add_to_cart( $request ) { /** * Filters the entire cart contents when the cart changes. * + * @since 2.5.0 + * * @internal Matches filter name in WooCommerce core. * * @param array $cart_contents Array of all cart items. @@ -147,6 +151,8 @@ public function add_to_cart( $request ) { * This hook fires when an item is added to the cart. This is triggered from the Store API in this context, but * WooCommerce core add to cart events trigger the same hook. * + * @since 2.5.0 + * * @internal Matches action name in WooCommerce core. * * @param string $cart_id ID of the item in the cart. @@ -251,6 +257,8 @@ public function validate_add_to_cart( \WC_Product $product, $request ) { * This filter will be deprecated because it encourages usage of wc_add_notice. For the API we need to capture * notices and convert to exceptions instead. * + * @since 7.2.0 + * * @deprecated * @param boolean $passed_validation True if the item passed validation. * @param integer $product_id Product ID being validated. @@ -300,6 +308,8 @@ public function validate_add_to_cart( \WC_Product $product, $request ) { * Fire action to validate add to cart. Functions hooking into this should throw an \Exception to prevent * add to cart from happening. * + * @since 7.1.0 + * * @param \WC_Product $product Product object being added to the cart. * @param array $request Add to cart request params including id, quantity, and variation attributes. */ @@ -411,6 +421,8 @@ public function validate_cart() { * * Functions hooking into this should add custom errors using the provided WP_Error instance. * + * @since 7.2.0 + * * @example See docs/examples/validate-cart.md * * @param \WP_Error $errors WP_Error object. @@ -437,6 +449,8 @@ public function validate_cart() { * This filter will be deprecated because it encourages usage of wc_add_notice. For the API we need to capture * notices and convert to wp errors instead. * + * @since 7.2.0 + * * @deprecated * @internal Matches action name in WooCommerce core. */ @@ -639,6 +653,8 @@ public function validate_cart_item( $cart_item ) { * Fire action to validate add to cart. Functions hooking into this should throw an \Exception to prevent * add to cart from occurring. * + * @since 7.1.0 + * * @param \WC_Product $product Product object being added to the cart. * @param array $cart_item Cart item array. */ @@ -831,6 +847,8 @@ protected function get_package_name( $package, $index ) { /** * Filters the shipping package name. * + * @since 4.3.0 + * * @internal Matches filter name in WooCommerce core. * * @param string $shipping_package_name Shipping package name. @@ -928,6 +946,8 @@ function( $code ) { /** * Filters if a coupon can be applied alongside other individual use coupons. * + * @since 2.6.0 + * * @internal Matches filter name in WooCommerce core. * * @param boolean $apply_with_individual_use_coupon Defaults to false. @@ -953,6 +973,8 @@ function( $code ) { /** * Filter coupons to remove when applying an individual use coupon. * + * @since 2.6.0 + * * @internal Matches filter name in WooCommerce core. * * @param array $coupons Array of coupons to remove from the cart. @@ -975,6 +997,8 @@ function( $code ) { /** * Fires after a coupon has been applied to the cart. * + * @since 2.6.0 + * * @internal Matches action name in WooCommerce core. * * @param string $coupon_code The coupon code that was applied. @@ -1114,6 +1138,8 @@ protected function filter_request_data( $request ) { /** * Filter cart item data for add to cart requests. * + * @since 2.5.0 + * * @internal Matches filter name in WooCommerce core. * * @param array $cart_item_data Array of other cart item data. @@ -1134,6 +1160,8 @@ protected function filter_request_data( $request ) { /** * Filter sold individually quantity for add to cart requests. * + * @since 2.5.0 + * * @internal Matches filter name in WooCommerce core. * * @param integer $sold_individually_quantity Defaults to 1. diff --git a/src/StoreApi/Utilities/ProductQuery.php b/src/StoreApi/Utilities/ProductQuery.php index 34f4d195198..bdb4262e947 100644 --- a/src/StoreApi/Utilities/ProductQuery.php +++ b/src/StoreApi/Utilities/ProductQuery.php @@ -466,6 +466,8 @@ protected function adjust_price_filter_for_tax_class( $price_filter, $tax_class * with out of base locations. e.g. If a product costs 10 including tax, all users will pay 10 * regardless of location and taxes. * + * @since 2.6.0 + * * @internal Matches filter name in WooCommerce core. * * @param boolean $adjust_non_base_location_prices True by default. diff --git a/src/StoreApi/Utilities/QuantityLimits.php b/src/StoreApi/Utilities/QuantityLimits.php index 1a1dc0a82f1..5bee2219e9f 100644 --- a/src/StoreApi/Utilities/QuantityLimits.php +++ b/src/StoreApi/Utilities/QuantityLimits.php @@ -153,6 +153,8 @@ protected function get_product_quantity_limit( \WC_Product $product ) { * * Filters the variation option name for custom option slugs. * + * @since 6.8.0 + * * @param integer $quantity_limit Quantity limit which defaults to 9999 unless sold individually. * @param \WC_Product $product Product instance. * @return integer @@ -198,6 +200,8 @@ protected function filter_value( $value, string $value_type, $cart_item_or_produ * The suffix of the hook will vary depending on the value being filtered. * For example, minimum, maximum, multiple_of, editable. * + * @since 6.8.0 + * * @param mixed $value The value being filtered. * @param \WC_Product $product The product object. * @param array|null $cart_item The cart item if the product exists in the cart, or null. diff --git a/src/StoreApi/Utilities/RateLimits.php b/src/StoreApi/Utilities/RateLimits.php index 6d791215a0e..27308e1a428 100644 --- a/src/StoreApi/Utilities/RateLimits.php +++ b/src/StoreApi/Utilities/RateLimits.php @@ -219,6 +219,8 @@ public static function get_options() { * * @param array $rate_limit_options Array of option values. * @return array + * + * @since 8.9.0 */ apply_filters( 'woocommerce_store_api_rate_limit_options', diff --git a/src/StoreApi/docs/cart.md b/src/StoreApi/docs/cart.md index 2a6185a1802..c6fef709b1a 100644 --- a/src/StoreApi/docs/cart.md +++ b/src/StoreApi/docs/cart.md @@ -519,3 +519,4 @@ Returns the full [Cart Response](#cart-response) on success, or an [Error Respon 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./src/StoreApi/docs/cart.md) + diff --git a/src/Templates/BlockTemplatesCompatibility.php b/src/Templates/BlockTemplatesCompatibility.php index 7032a6357eb..b0b7120a935 100644 --- a/src/Templates/BlockTemplatesCompatibility.php +++ b/src/Templates/BlockTemplatesCompatibility.php @@ -300,6 +300,8 @@ protected function remove_default_hooks() { * - priority is the priority of the hooked function. * * @param array $data Additional hooked data. Default to empty + * + * @since 9.5.0 */ $additional_hook_data = apply_filters( 'woocommerce_blocks_hook_compatibility_additional_data', array() ); @@ -327,6 +329,11 @@ protected function get_hooks_buffer( $hooks, $position ) { ob_start(); foreach ( $hooks as $hook => $data ) { if ( $data['position'] === $position ) { + /** + * Action to render the content of a hook. + * + * @since 9.5.0 + */ do_action( $hook ); } } diff --git a/templates/emails/customer-new-account-blocks.php b/templates/emails/customer-new-account-blocks.php index 353b94060ac..52cd293d04f 100644 --- a/templates/emails/customer-new-account-blocks.php +++ b/templates/emails/customer-new-account-blocks.php @@ -10,7 +10,13 @@ */ defined( 'ABSPATH' ) || exit; - +/** + * Fires to output the email header. + * + * @hooked WC_Emails::email_header() + * + * @since 3.7.0 + */ do_action( 'woocommerce_email_header', $email_heading, $email ); ?> @@ -28,5 +34,11 @@ if ( $additional_content ) { echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) ); } - +/** + * Fires to output the email footer. + * + * @hooked WC_Emails::email_footer() + * + * @since 3.7.0 + */ do_action( 'woocommerce_email_footer', $email ); diff --git a/templates/emails/plain/customer-new-account-blocks.php b/templates/emails/plain/customer-new-account-blocks.php index d5130a072ce..b3853523fb7 100644 --- a/templates/emails/plain/customer-new-account-blocks.php +++ b/templates/emails/plain/customer-new-account-blocks.php @@ -35,4 +35,11 @@ echo "\n\n----------------------------------------\n\n"; } +/** + * Filters the email footer text. + * + * @since 3.7.0 + * + * @param string $footer_text Footer text. Default empty. + */ echo wp_kses_post( apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ) );