Commit Graph

82 Commits

Author SHA1 Message Date
Vedanshu Jain 03ba8838b1
Merge pull request #29099 from woocommerce/fix/27376
Make the refunds creation REST API behave more as documented
2021-02-18 14:25:38 +05:30
Claudio Sanches 6fae8ca40b
Merge pull request #29146 from woocommerce/fix/27290-rest-api-order-updates
Throw an error if a coupon item ID (readonly) is specified during an order update | #27290
2021-02-16 17:04:49 -03:00
barryhughes 24e0191dc7 Throw a 400 error if a coupon item ID (readonly) is posted/put during an order update | #27290 2021-02-16 09:59:03 -08:00
Nestor Soriano 4e195d5f3f Fix code sniffer errors. 2021-02-12 15:29:32 +01:00
Nestor Soriano 00d6dc40f7 Fix wrong caching of taxonomy in terms and attributes controllers.
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.
2021-02-12 15:12:58 +01:00
Nestor Soriano fae00e2bdf Make the refunds creation REST API behave more as documented
- 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.
2021-02-11 09:51:13 +01:00
Claudio Sanches ea54d5ad5f
Merge pull request #28679 from woocommerce/fix/woocommerce-gutenberg-products-block-issues-3565
Show correct WooCommerce pages status if they are using blocks vs shortcode.
2021-01-18 19:26:34 -03:00
budzanowski f9cbc0ccac Remove filters that we don't need yet. 2021-01-14 10:24:39 +01:00
vedanshujain f8bcf6271d Revert order and product controllers to use WP Post queries directly.
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.
2021-01-07 16:47:54 +05:30
budzanowski 1cf09eb063 Simplify. 2021-01-06 15:30:13 +01:00
budzanowski d5babd800a Review refactor. 2021-01-06 15:28:51 +01:00
vedanshujain 27b22d3aaa Move the logic to set stock_status from V2 to V3. 2021-01-06 17:55:56 +05:30
budzanowski 29837c42ff Refactor. 2021-01-06 11:33:28 +01:00
vedanshujain 2ae6c5b543 Also fetch dependencies for fields which are computed from other fields. 2021-01-06 15:09:50 +05:30
vedanshujain 0d43aecebd Also fetch in_stock when stock_status requested in V2.
When called from V3, controller calls V2s get_product_data method, where stock_status was did not existed and was renamed. In V3 controller, we compute it based on V2 in_stock field.
2021-01-06 14:14:59 +05:30
budzanowski 325f72afe1 Merge branch 'master' into fix/woocommerce-gutenberg-products-block-issues-3565 2021-01-06 09:01:17 +01:00
jonathansadowski 1e267980e8
Merge pull request #28723 from woocommerce/feature/issue-27208
Feature/issue 27208
2021-01-05 14:00:55 -06:00
roykho b25f01d2f3
Add unit tests 2021-01-05 08:14:39 -08:00
vedanshujain 3a7e3fda34 Use `!empty` for consistency with other usages. 2021-01-05 16:37:39 +05:30
vedanshujain 80f5d35311 Apply coding standards w.r.t PR #28677 2021-01-05 13:47:16 +05:30
roykho 7b091485a2
Create product tags if they don't exists closes #27208 2021-01-04 14:59:28 -08:00
budzanowski c81df313b2 Add block information for woocommerce pages report. 2020-12-28 16:19:51 +01:00
vedanshujain 818e24d5c5 Add protection around `func_get_arg` method for backward compatibility.
We are using func_get_arg method to receive argument in a backward compatible way since we cannot modify function signature to add more params even with default params. Earlier I was hoping to use DI to create another child class with modified signature and load it depending upon where we are executing from, however since we had to revert DI, we add this workaround to unblock #27735.
2020-12-28 14:10:22 +05:30
vedanshujain 934b10fb8c Use wc_get_orders for consistency intead of custom query 2020-12-18 14:40:20 +05:30
vedanshujain 089994c618 Dont fetch optional fields unless asked to improve performance 2020-12-18 14:40:20 +05:30
vedanshujain 04f948951a Fetch product attrs only when needed 2020-12-18 14:40:20 +05:30
vedanshujain 13bee82ed9 Cover missed cases 2020-12-18 14:40:20 +05:30
vedanshujain 54dd5550e5 Pass request in backward compatible way 2020-12-18 14:40:20 +05:30
vedanshujain e62169a4b5 Cache return fields for perfromance 2020-12-18 14:40:20 +05:30
vedanshujain 2e65b8cec4 Fetch expensive fields only when required for performance 2020-12-18 14:40:20 +05:30
Claudio Sanches e8b2a9adab Display *-product_<cat|tag> template overrides in Status page 2020-11-23 20:12:38 -03:00
Vedanshu Jain ae163eb28b
Merge pull request #27734 from woocommerce/enhancement/optimize-wc-order
Optimize function `wc_get_orders` by priming caches beforehand
2020-11-14 12:37:44 +05:30
vedanshujain 62ae94d93e Add shipping, tax and fee lines to refund response for better information. 2020-11-11 18:47:48 +05:30
vedanshujain a5fb3178f0 Drop CacheHydration class and do it directly.
Primary reason for dropping the cache hydration is that seems like we can acheive the same results without it, so no need to add this additional complexity to our code.
2020-11-10 14:23:43 +05:30
Shiki 94ecfcab34 Orders API: Add parent_name to schema 2020-10-26 13:28:04 -03:00
Shiki 48d595ed71 Orders API: Reorganize and place parent_name in a separate section 2020-10-26 13:28:04 -03:00
Shiki 52739ba9ee Orders API: Add parent_name to line_items for variable products 2020-10-26 13:28:04 -03:00
Claudio Sanches 27e4288eab
Merge pull request #27934 from woocommerce/remove_get_product_from_item
Remove the remaining uses of $order->get_product_from_item()
2020-10-14 16:18:29 -03:00
Claudio Sanches 7d1ff1a655
Merge pull request #27310 from woocommerce/fix/27215
Fix deleting a tax class via WP CLI.
2020-10-14 14:00:33 -03:00
Ron Rennick 8ec54fabe0 phpcs fixes 2020-10-14 10:27:58 -03:00
Ron Rennick cd20044b13 Merge branch 'master' into fix/27215 2020-10-14 10:16:36 -03:00
vedanshujain c01f32a390 Use default value if formatted value is not available 2020-10-14 14:51:19 +05:30
vedanshujain 8e12de5d3c Merge branch 'fix/api/229-unit-test' of https://github.com/shiki/woocommerce into fix/api/229 2020-10-14 13:53:03 +05:30
Claudio Sanches e655b44717 Fixed coding standards 2020-10-13 22:32:32 +05:30
Shiki 2e165e7558 Orders: Make display_key and _value meta available for v3 and v3
This resolves the intentionally failing
WC_Tests_API_Orders_V2::test_get_item_with_line_items_meta_data.
2020-10-13 22:32:31 +05:30
Shiki a3f46e5526 Schema: Make display_key and *_value available for v3 and v2
This is just the schema and the actual functionality isn't implemented yet.
2020-10-13 22:32:30 +05:30
Shiki b9ae830da5 Fix formatting in Orders V2 unit test 2020-10-13 22:32:30 +05:30
Shiki f45e8b884b Orders V3: Reuse WC_Order_Item->get_formatted_meta_data
Previously, I was using my own function. This time, we're using the function
available in WC_Order_Item but sanitizing the results after.
2020-10-13 22:32:30 +05:30
Shiki 2e92460df2 Orders V3: Include display_key and display_value in item meta_data 2020-10-13 22:32:30 +05:30
Shiki d8ac282c80 Orders V3 Schema: Add display_key and display_value for meta props 2020-10-13 22:32:29 +05:30