Commit Graph

51 Commits

Author SHA1 Message Date
Mike Jolley f248902454 Update versions 2020-04-03 15:56:43 +01:00
Mike Jolley 4faea42c23 Change priorities 2020-04-03 15:55:15 +01:00
Mike Jolley e965f854d6 Missing class name 2020-04-03 15:55:15 +01:00
Mike Jolley c983677a6f Implement stock functions 2020-04-03 15:55:15 +01:00
vedanshujain 3bd34184e4 Fixed bool error on when to disable feature 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
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
Claudio Sanches a12c25862b
Revert "Add support for '_held_for_checkout` records to prevent race conditions." 2019-12-04 16:03:05 -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
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
Sören Schwert c22fcfd98f
Correct comments in stock increase methods
Fixes some comments and a variable name in the stock increase methods.

There is however a logic problem remaining, I think, where the value taken for the per-item `_reduced_stock` meta value falls back to `true` when the meta key does not exists (line 266), however the key is deleted at the end of the loop (line 281), thus allowing the `wc_increase_stock_levels` methods to increase the stock again when re-run directly.
2019-09-27 11:28:46 +02:00
Chris Eich 354b248b28
Only count orders created via checkout in held stock qty
Plugins may create orders without the meta tag "_created_via"="checkout" for various purposes, e.g. a balance-due order for purchases via deposit, because only the deposit order should reduce stock on checkout. The SUMO Payment Plans plugin does exactly this, but core WC handles such orders inconsistently:
- wc_get_held_stock_quantity() counts their items against held stock, but
- wc_cancel_unpaid_orders() only cancels old orders with a meta tag of "_created_via"="checkout"

This PR fixes that inconsistency, which on my site was preventing a user from adding an in-stock product to her cart, just because a balance-due order for the same product was pending.

Workaround: clear the setting WC > Products > Inventory > Hold Time (default 60 minutes), which inhibits the use of wc_get_held_stock_quantity().
2019-07-15 21:59:02 -07:00
Peter Fabian 1d29b36c4c Removed comments that are no longer relevant. 2019-05-15 15:46:53 +02:00
Peter Fabian 35c63ee475 Added some comments to hopefully make the function a bit clearer. 2019-05-02 20:19:28 +02:00
Mike Jolley 1a1b3e7654 Improved wc_update_product_stock
Allow product object to be passed through, remove cache clearing which is done during save(), and allow the caller to define whether or not an update routine is already in progress.
2019-04-26 17:20:50 +01:00
Mike Jolley 0cd429dad9 Avoid post update in wc_update_product_stock 2019-04-09 12:47:51 +01:00
Mike Jolley 600510ea6f Using wrong post type name in comparison 2019-02-04 13:56:35 +00:00
Gerhard a3f3b282ac Initialise $changes before usage. 2018-11-15 14:36:56 +02:00
Joey Gilham 58cdd7dad2
Merge branch 'master' into master 2018-07-03 15:41:15 +01:00
Joey 4e0412e0d8 removed redundant trigger for low stock notifications 2018-07-03 14:48:53 +01:00
Joey 375ef48186 updated wc_get_low_stock_amount function 2018-07-03 14:42:58 +01:00
Joey cd8416122f removed low stock options for variations, and addressed changes 2018-06-19 12:40:27 +01:00
Mike Jolley e92463632b Held stock qty check for pay page 2018-06-08 16:58:33 +01:00
Mike Jolley d76474789d variable name 2018-06-08 16:30:58 +01:00
Mike Jolley 52854b7690 Add qty to order via modal, include stock qty in formatted name display for reference 2018-06-08 16:18:32 +01:00
Mike Jolley 8084100cbb Tweak meta naming and order notes 2018-06-08 12:18:33 +01:00
Mike Jolley 2657db4a97 Pending should restore stock too 2018-06-07 17:42:58 +01:00
Mike Jolley 70c9cff608 Increase/decrease stock handling 2018-06-07 17:41:36 +01:00
Joey e5800b66b0 updated low_stock_amount fields to use global value if no value is entered 2018-05-27 06:43:23 +01:00
Joey 5f36ba44cd variable product confirmed before processing low stock notifications in function 'wc_update_product_stock' 2018-05-27 05:49:01 +01:00
Joey b08b55a651 added changes for low stock notifications per product 2018-05-27 05:40:58 +01:00
Mike Jolley 06ef8c8589 Hook doc update 2018-05-02 14:28:53 +01:00
Claudio Sanches d20f348d3c Check if $product exists 2018-03-08 18:33:16 -03:00
Claudio Sanches cf9ce1add8 Fixed includes/wc-stock-functions.php PHPCS violations 2018-03-08 16:44:52 -03:00
Mike Jolley 54d4012c33 Use timestamp function 2017-12-07 15:24:57 +00:00
Caleb Burks 6374a13d30 Update a product’s modified_date for stock changes 2017-12-05 00:53:52 -06:00
Rasmus Bengtsson 4f00d7e5e3 PHPDoc: Add missing return statement 2017-05-15 13:37:59 +02:00
Mike Jolley d9a8de7c16 Ensure order object exists and pass through to avoid requery 2017-05-09 18:20:42 +01:00
Beka Rice 1c240bb014 Use order data store for stock checks in case of custom order types 2017-05-08 17:58:01 -04:00
Beka Rice adf0851117 Fix: mark stock as reduced in wc_reduce_stock_levels() 2017-05-04 03:52:38 -04:00
claudiulodro 01a6b3bae0 Get updated product before doing low stock actions 2017-04-19 15:32:51 -07:00
Claudio Sanches 59c2849736 Changed version 2.7 to 3.0 2017-03-15 13:36:53 -03:00
Claudiu Lodromanean 07a021760a 13320 Delete cached object when updating stock 2017-02-23 12:56:34 -08:00
Mike Jolley 88280d7756 Fix: Wrong product object 2017-02-17 16:28:11 +00:00
Mike Jolley a0483a30dc Clear children on stock update
Closes #13218
2017-02-17 16:25:45 +00:00
Mike Jolley 365b456fa5 Make sure product is set. 2017-01-27 16:39:53 +00:00
Manos Psychogyiopoulos af378a619d fix undefined qty_ordered variable 2017-01-03 21:40:06 +02:00
Mike Jolley b1565cf0d6 Download update routine and interface 2016-11-18 19:29:37 +00:00
Justin Shreve 90e43d97de [Product CRUD] Product Datastore (#12317)
* Fix up tests in the product/* folder.

* Handle data store updates for grouped, variable, external, simple, and general data store updates for products.

* Variations & variable changes.

* Update -functions.php calls to use data store.

* Add an interface for the public product data store methods.

* Finished product factory tests

* Correctly delete in the api, fix up some comments, and implement an interface for the public variable methods.

* Fix up delete in all versions of the api

* Handle feedback

* Match protected decloration to parent
2016-11-11 14:31:15 +00:00
Mike Jolley 09ea4ba91f [Product CRUD] Variable, variation, notices, and stock handling (#12277)
* No longer needed

* Remove old todos

* Use getters in admin list

* Related and upsells update for CRUD

* Fix notice in gallery

* Variable fixes and todos

* Context

* Price sync

* Revert variation attributes change

* Return parent data in view context

* Defer term counting

* wc_find_matching_product_variation

* Stock manage tweaks

* Stock fixes

* Correct id

* correct id

* Better sync

* Data logic setter fix

* feedback
2016-11-09 16:10:37 +00:00