Two new optional keys have been added to the tool definition array:
- 'disabled': when true the tool button will appear disabled.
- 'needs_refresh': when running a tool, by default the tool definitions
are retrieved first, then the selected tool is executed,
then the definitions previously retrieved are rendered.
When this key is true the tool definitions are retrieved again
after execution, useful for cases where the tool description
or button enable/disable state changes after the tool execution.
Also now if a tool execution throws an exception a notice will be
shown with the execption message, previously the exception
was unhandled.
- Check input (no 'id', has 'code') and throw an error if needed
before removing the existing coupons, so an invalid input
won't cause the loss of these existing coupons.
- Also, check that the coupon is actually valid as part of the
input check.
- Cache the coupon objects that are created during the input check,
and apply them directly.
- Don't check if 'coupon_lines' is an array and contains arrays,
that's already done by the REST API engine by looking at the schema.
- Adjust unit tests.
The WC_REST_Terms_Controller and WC_REST_Product_Attributes_V1_Controller
classes have a get_taxonomy method that gets the name of the taxonomy
to process from a taxonomy id passed in the request, but once the
taxonomy name has been obtained it's cached and sbsequently reused.
The problem is that these controller instances are reused if more than
one request is processed programmatically, and thus the taxonomy that
was cached once is always used even if the new request specifies a
different taxonomy id.
The fix consists of using a dictionary of taxonomy id - taxonomy name
instead of one single taxonomy for caching.
In the case of WC_REST_Terms_Controller there's a protected $taxonomy
property that needs to be kept for compatibility, it's now set to
the last taxonomy name that has been introduced in the dictionary.
- Allow the list of line items to be a non-associative array
where each item is identified by an "id" field
- Same for taxes inside line items, specify amount to refund in
a "refund_total" key as in the case of line items
- Allow "quantity" keys as synonyms of "qty"
Also calculate "amount" automatically if missing and when all the
line items and taxes have a valid "refund_total" key.
This commit revert some of the changes added in #27735 because wc_get_products and wc_get_orders is not fully compitable with API controller queries. Since we are close to release 4.9, its better to revert and fix them properly then rush a fix. This undones some the performance improvements we acheived in 27735, in favor of more stability, hopefully we will be able to restore this soon.