Commit Graph

1014 Commits

Author SHA1 Message Date
Julià Mestieri b2c35a5ded Added cache and filters for wc-customer get operations. 2020-08-17 11:25:54 +02:00
Christopher Allford 7340c9af44
Merge pull request #27171 from woocommerce/fix/25543
Added the parent's SKU to product searches for variations
2020-08-12 12:58:00 -07:00
Claudio Sanches 02cf0dfaed
Merge pull request #27239 from woocommerce/fix/package-tag
Fix usage of "package" tag in file headers
2020-08-07 13:37:24 -03:00
Néstor Soriano 76cf1e4e93
Merge pull request #27140 from woocommerce/fix/23790
Always sanitize coupon code to prevent inconsistent between admins and shop owners
2020-08-07 12:42:02 +02:00
Claudio Sanches 525db3aa21 Fixed incorrect package tags 2020-08-05 17:49:10 -03:00
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
Claudio Sanches 7f233951a5 Fixed class package tag 2020-08-04 22:30:11 -03:00
Christopher Allford 78bff3b2da Added the parent's SKU to product searches for variations
Since the parent's SKU is used when the variation does not have one, we should fall back when searching for consistency.
2020-07-29 16:53:36 -07:00
Claudio Sanches 119b5d6568
Merge branch 'master' into fix/23790 2020-07-28 13:07:17 -03:00
Néstor Soriano e9d692f455 Apply suggestions from code review
Mostly adding "since 4.4.0" annotations and updating
db update functions from 4.2 to 4.4.

Co-authored-by: Claudio Sanches <contato@claudiosanches.com>
2020-07-28 09:01:55 +02:00
Nestor Soriano 9c6c0d73d8 Record attribute terms for product variations in wp_term_relationships.
Product attributes are currently recorded as terms in
wp_term_relationships (product attributes are actually taxonomies).
In the case of variable products this is true for the main product,
but not for the variations. The attributes used to define variations
are stored as post meta, but nothing is recorded in the term
relationships table.

This is a problem when using the layered nav filtering plugin,
since the attribute counters displayed are calculated based solely
on the contents of the term relationships table. Adding meta queries
would be really messy (especially when the widget is configured
with AND operator) and would probably also hurt performance.

This commit adds a change to store the attributes for variations
as term relationships, additionally to storing them as post meta.
Terms are stored on variation creation, and updated/deleted together
with the variation as appropriate. "Any" variations (stored in meta
as empty values) are not stored as terms.

Additionally, a database upgrade is included in order to backfill
terms for already existing products.
2020-07-28 08:55:55 +02:00
Nestor Soriano 752b47513d Fix code sniffer errors in some files.
Fixed files:

includes/data-stores/class-wc-product-variable-data-store-cpt.php
includes/wc-update-functions.php
2020-07-28 08:55:55 +02:00
Claudio Sanches e94196cea8 Sanitize coupon code in coupon ID by code functions 2020-07-27 17:33:15 -03:00
Claudio Sanches 9c4ac29137
Merge pull request #26565 from woocommerce/fix/26510
Allow set "order key" while creating order via CRUD
2020-07-01 12:42:18 -03:00
Claudio Sanches cac529c393
Merge pull request #26567 from woocommerce/fix/26510-created-date
Allow set "date_created" while creating orders via CRUD
2020-07-01 12:40:43 -03:00
Vedanshu Jain b45373fe0c Revert "Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout"" 2020-06-05 15:18:01 +05:30
Claudio Sanches 7534e2eba0 Allow set "date_created" while creating orders via CRUD 2020-05-20 18:04:49 -03:00
Claudio Sanches ea19190d3b Allows to set custom order_key while creating an order 2020-05-20 17:14:17 -03:00
Christopher Allford 8332410939
Merge pull request #26308 from vandekul/master
Fix matching zones query for working with sqlite
2020-05-11 19:58:17 -07:00
Claudio Sanches 85d7cdbbb4 Allow schedule coupons via CRUD 2020-05-05 16:35:10 -03:00
Susanna 07eef2d717
Fix matching zones query for working with sqlite
And probably other databases too.
2020-04-27 18:31:52 +02:00
Vedanshu Jain ee119e0a7e
Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout" 2020-04-21 15:37:21 +05:30
Claudio Sanches 58db7314a8 Added validation for product fields. 2020-04-07 11:29:54 +02:00
Vedanshu Jain 3bf473517d
Merge pull request #25708 from woocommerce/update/reserve-stock-for-checkout
Introduce a `reserved stock` class and database table to prevent race conditions during checkout
2020-04-07 02:16:22 +05:30
Mike Jolley 51aca598b9 Only implement get_query_for_stock in data store 2020-04-03 15:55:14 +01:00
Claudio Sanches 2ebd86f2dc Revert "Revert "Add support for '_held_for_checkout` records to prevent race conditions."" 2020-04-03 15:55:13 +01:00
Gennady Kovshenin ca996a8941 Fix race condition in update_product_stock
Modify the increment and decrement SQL query in
WC_Product_Data_Store_CPT::update_product_stock to be atomic. This fixes
a race condition in concurrent order placement.
2020-03-31 16:01:26 +03:00
vedanshujain 509b2c180d Set usage count as its required by usages query 2020-03-11 20:44:52 +05:30
Rodrigo Primo 0aa438e031 Add version to @since tag of WC_Coupon_Data_Store_CPT::updated_props
See #25755
2020-03-04 15:57:17 -03:00
Rodrigo Primo 831b02a0a6
Merge pull request #25755 from nefeline/fix/undefined-property-coupon-post-meta-update
Fix > Undefined property error when updating the coupon post meta
2020-03-04 15:56:24 -03:00
Christopher Allford 37ff503855 Adjusted the ordering of the cache clear on order item deletion to prevent leaving behind a ghost cache entry 2020-02-26 09:36:28 -08:00
Christopher Allford 165138fc30 Renamed the WC_Order_item_Data_Store::clear_cache method to be consistent with other data stores. 2020-02-26 09:34:27 -08:00
Patricia Hillebrandt c3379482a2 Updating docblock 2020-02-25 16:53:40 +01:00
Christopher Allford 6a292de9f9 Cleared the cache when order items are added, updated, or deleted 2020-02-23 12:41:33 -08:00
Christopher Allford e2a09ac1a7 Added a cache clearing method to the order item data store
The order items utilize caching, but the cache is never cleared. This will allow us to resolve this issue in a way consistent with other data stores.
2020-02-23 12:11:23 -08:00
Patricia Hillebrandt bd53e2eb60 Prevents the Undefined property error when updating the post meta for a given coupon 2020-02-23 14:07:18 +01:00
Rodrigo Primo 7c9d6110e2 Fix typo in code comment 2020-02-05 15:48:40 -03:00
Christopher Allford 57734ca8ce Merge branch 'master' into refactor/add-jetpack-constants 2020-02-04 14:36:35 -08:00
Christopher Allford 1d1413b4ee Replaced direct access of many constants with the Constants library 2020-01-31 22:18:47 -08:00
Mike Jolley 314cc8eee6 Add columns to data store 2020-01-20 14:17:42 +00:00
Rodrigo Primo 2668bf6025
Merge pull request #25314 from woocommerce/fix/24746
Removed the lowercase conversion of product search terms
2020-01-16 16:29:07 -03:00
Claudio Sanches 3ebda4a431 Use WC_Data_Exception in WC_Product_Variation_Data_Store_CPT 2020-01-06 21:35:23 -03:00
Claudio Sanches 85a077b939 Coupon race condition prevention 2020-01-06 19:44:24 -03:00
Christopher Allford 874be93c14 Removed the lowercase conversion of product search terms
When searched in a case sensitive manner, the conversion to lowercase causes uppercase matches that would have been found to be lost. This change increases the tolerance of the OR search format while also removing this unintended side-effect.
2019-12-24 15:00:40 -08:00
Rodrigo Primo 7337ab60c2 Fix PEAR.Functions.FunctionCallSignature violations
This commit fixes all violations of the PEAR.Functions.FunctionCallSignature sniff automatically using phpcbf.
2019-12-20 15:25:23 -03:00
Rodrigo Primo 487f96d844 Fix WordPress.DateTime.CurrentTimeTimestamp vilations
This commit fixes all violations of the WordPress.DateTime.CurrentTimeTimestamp sniff automatically using phpcbf.
2019-12-20 14:23:05 -03:00
Rodrigo Primo 62d6b05b58 Fix Generic.Formatting.MultipleStatementAlignment violations
This commit fixes all violations of the Generic.Formatting.MultipleStatementAlignment sniff automatically using phpcbf.
2019-12-20 14:21:08 -03:00
vedanshujain ad2f76275a Applied coding standards 2019-12-17 19:13:19 +05:30
vedanshujain ba2d825800 Use DB timestamp to ensure consistency between servers. 2019-12-17 19:13:19 +05:30
vedanshujain 9b7343d23b Applied coding standards 2019-12-17 19:13:19 +05:30
vedanshujain 47ba1d49da Cascade to return null to prevent notice when array is empty.
Another situation where this change is required when there are two coupons in an order but only one coupon has limit. In this case array will be present but one of the coupon will not have a corresponding record which will throw a notice.
2019-12-17 19:13:19 +05:30
vedanshujain 53bfcea110 Use same filter for stocks and coupon for consistency. 2019-12-17 19:13:19 +05:30
vedanshujain 72545c44b7 Add support for `_held_for_checkout` records to improve performance.
This will also improve transactional stability and avoid race conditions by providing a way to lock usage counts.
2019-12-17 19:13:19 +05:30
Claudio Sanches f7632de06e
Merge pull request #25164 from om4james/webhook-delete-cache
Delete cached webhook data when a webhook is deleted
2019-12-10 22:45:42 -03:00
Claudio Sanches 104f40c36e
Merge pull request #24281 from woocommerce/fix/24269
Handle multiple decimal points
2019-12-09 14:07:29 -03:00
Claudio Sanches 78e382e4d6 Fixed incorrect concatenation of variation sale prices with ".00" 2019-12-06 12:37:23 -03:00
James Collins 0246b02a94 Merge branch 'master' into webhook-delete-cache 2019-12-06 08:57:54 +08:00
Rodrigo Primo 27915dd696 Exception when WC_Product_Variation is instantiated with the wrong type
This commits changes WC_Product_Variation to raise an exception when the
class is instantiated with an ID that belongs to a post object that is
not a product variation.

This is necessary to avoid problems like the one described in #24956
where passing a variable product ID to WC_Product_Variation would result
in transparently modifying the variable product title and excerpt.
2019-12-05 15:45:48 -03:00
Rodrigo Primo 61a843679a Fix WPCS violations automatically using phpcbf 2019-12-05 15:45:12 -03:00
Claudio Sanches 5fdb880831
Merge branch 'master' into feature/24956 2019-12-04 16:18:39 -03:00
Claudio Sanches 8033d5751e Changed wc_get_product_classname function name to wc_get_product_object 2019-12-04 16:15:16 -03:00
Claudio Sanches a12c25862b
Revert "Add support for '_held_for_checkout` records to prevent race conditions." 2019-12-04 16:03:05 -03:00
James Collins b29f8cc1bd Deleted cached webhook data when deleting a webhook 2019-12-04 12:04:35 +08:00
Claudio Sanches 258066dc2b
Merge pull request #25077 from woocommerce/update/coupon-object-update-hook
Fix second param of action hook woocommerce_coupon_object_updated_props
2019-12-03 17:53:04 -03:00
Claudio Sanches 0c486785ad
Merge pull request #25089 from woocommerce/fix/24009
Add support for '_held_for_checkout` records to prevent race conditions.
2019-12-03 17:47:22 -03:00
Claudio Sanches 988b72e461 Updated filter name to woocommerce_hold_stock_for_checkout
Also fixed coding standards
2019-12-03 16:38:17 -03:00
Peter Fabian 309c48ab0e Deprecated old cache function and replaced it with a new one. 2019-11-28 14:03:57 +01:00
vedanshujain e87024bb81 Add support for '_held_for_checkout` records to prevent race conditions.
When creating an order, if manage inventory is enabled then add a `_held_for_checkout` record with a expiry timestamp embedded. This is added in an atomic manner along with making a check whether we have current stock or not.
This record is removed when order status goes to either `processing` or `completed`.
2019-11-21 01:21:08 +05:30
Gerhard 2a4a1a5842 Remove unused $updated_props variable 2019-11-20 14:47:44 +02:00
Michael Weichselgartner 2092da00c4 Fix second param of action hook woocommerce_coupon_object_updated_props
Changed second param from $updated_props to $this->updated_props
2019-11-20 14:42:09 +02:00
Claudio Sanches ba0773d12e Apply wc_get_product_classname() in the current code base 2019-11-13 15:30:09 -03:00
Peter Fabian 3cbea2a902 Simplify 'any-check' to only include empty string. 2019-10-02 16:58:45 +02:00
Peter Fabian 4cfe22eef9 Made the attribute value comparison strict. 2019-10-02 16:05:44 +02:00
Peter Fabian 258e49a8de Allow attribute value 0 to work correctly with variations (especially add to cart and select variation). 2019-10-02 14:58:40 +02:00
Vedanshu Jain 7081c64115
Merge pull request #24294 from woocommerce/fix/24106
Make WC_Product_Query capable to sort products by "include" order
2019-10-02 18:02:06 +05:30
Rodrigo Primo b033c110db
Merge pull request #24229 from rynaldos/woocommerce_update_product_stock_query-changes
Use $new_stock in woocommerce_update_product_stock_query
2019-09-24 18:01:10 -03:00
Rodrigo Primo c3262eea3e
Merge pull request #24385 from woocommerce/fix/24356
Ensure WC_Product_Data_Store_CPT::is_existing_sku() return boolean
2019-08-21 16:52:13 -03:00
Gerhard 5a1615a152 PHPCS fix 2019-08-12 20:26:34 +02:00
Rodrigo Primo f687412acd
Merge pull request #24353 from woocommerce/fix/24334
Avoid PHP notice when getting order item type
2019-08-12 14:11:41 -03:00
Claudio Sanches 66dbb44100 Ensure WC_Product_Data_Store_CPT::is_existing_sku() return boolean 2019-08-12 12:45:43 -03:00
Rodrigo Primo 6c263c97b6
Merge pull request #24239 from Chouby/fix/delete_variations_actions
Fire related actions when deleting all product variations
2019-08-08 16:47:39 -03:00
Rodrigo Primo 21418bb28b Avoid PHP notice when getting order item type
This commit changes WC_Order_Item_Data_Store::get_order_item_type() to
avoid a PHP notice ("Notice: Trying to get property 'order_item_type' of
non-object") when there is no entry in the database for the order item
ID passed.
2019-08-07 18:03:26 -03:00
Mahdi Yousefi 449a258781
Remove whitespace at end of line 2019-08-07 11:26:28 +04:30
Mahdi Yousefi c2d05b1fc0
Update class-wc-shipping-zone-data-store.php 2019-08-07 08:34:14 +04:30
Claudio Sanches d624bb57d5 Fixed coding standards 2019-08-01 15:56:02 -03:00
Claudio Sanches decea3d28c Allow sort products by "include" order 2019-08-01 15:55:32 -03:00
Frédéric Demarle 0fa582a25f Coding standards 2019-07-26 13:40:13 +02:00
Frédéric Demarle e3dd09d021 Fire related actions when deleting all product variations 2019-07-26 11:55:30 +02:00
rspublishing bb2c929fba Use in woocommerce_update_product_stock_query 2019-07-25 09:31:37 +02:00
MahdiY 040a617cd1 Add filter hook to get zone criteria 2019-07-19 09:35:04 +04:30
Gerhard Potgieter 60b385ea93
Merge pull request #23268 from Spreeuw/patch-8
store tax rate percent in tax line items
2019-07-14 18:42:10 +02:00
Claudio Sanches 60c18ce544
Merge pull request #23067 from woocommerce/pr/23043
Allow matching of "any" attributes in find_matching_product_variation…
2019-07-12 12:40:53 -03:00
Ewout Fernhout 6fe857f718 Merge remote-tracking branch 'origin/master' into patch-8 2019-07-11 14:44:39 +02:00
Gerhard Potgieter 2734b190c1
Merge pull request #23881 from ionutcalara/master
Update find matching variation method inner query
2019-07-10 15:53:30 +02:00
Claudio Sanches 32996d2fdd Merge branch 'master' into pr/23043 2019-07-09 12:39:40 -03:00
Claudio Sanches 01f5a09d27
Merge pull request #23338 from woocommerce/update/23335
More useful actions in during CRUD save events
2019-07-08 18:56:14 -03:00
oscargare 2c8e45830a Added new action "woocommerce_product_read" (#23181)
* Added new action "woocommerce_read_product_data"

* Added new action woocommerce_product_read
2019-07-04 14:17:34 -03:00
Claudio Sanches 1f73c63a57
Merge pull request #23909 from woocommerce/fix/23895
Explicitly check 0 value attributes when looking up variations.
2019-06-24 12:35:39 -03:00
Claudio Sanches 3ce6acec74 Updated outdated codex URLs 2019-06-12 19:31:01 -03:00
Gerhard 3894d156e6 Explicitly check 0 value attributes when looking up variations. 2019-06-12 11:27:27 +02:00