Commit Graph

125 Commits

Author SHA1 Message Date
vedanshujain 892b7caa37 Stock managment fixes:
1. Use $already_reduced_stock instead of also considering $refunded_item_quantity while deleting orders. This will bring back part of #27504 again, but for now this seems to be the best solution for countering #28605. It needs discussion whether deleting a line item completely should also undo any refund related changes on it or not.

2. Also mark `stock_reduced` flag on order if any of the line item has any `_reduced_stock` flag. This will allow for stock restoring logic to work properly when order is cancelled.

3. Only adjust line item stock when order is in `processing`, `completed` or `on-hold` status state, because we need to reduce stocks on these status only. Stock adjustments in refunds or when changing statuses is already taken care of by their specific hooks.
2020-12-17 22:28:21 +05:30
roykho 134786ada8 Fix stock reducing incorrect amount when order item is deleted after a refund closes #27504 2020-11-11 15:28:06 -06:00
vedanshujain c69e1f5799 Remove protection as we already diff and update only if needed.
In #26642 we removed adding reduced_stock meta when adding new order item to prevent ghost entries, but in inadvertently exposed an underlying bug where _reduced_stock meta was getting set to 0 if its emtpy.

We were then checking the presence of this meta, but also not reducing the stock in case it was not set.
2020-09-24 00:54:24 +05:30
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
Claudio Sanches a464b7aeab Improved wc_get_current_admin_url()
- Replace "/wp-admin" with regex like on WP core.
- Remove "wc-hide-notice" from query args.
2020-07-29 21:01:39 -03:00
Claudio Sanches c9f52a45eb New wc_get_current_admin_url() function 2020-07-29 20:52:36 -03:00
Claudio Sanches d498341f0e Added function to get current admin page 2020-07-29 20:37:12 -03:00
abhishek-pokhriyal b049d29a8a Change "though" to "through" 2020-04-11 19:35:13 +05:30
Gerhard 216a86b558 Change filter name to woocommerce_show_invalid_variations_notice and also pass through the $product_object variable. 2019-12-05 08:08:07 +02:00
Gerhard 40faecc8e7 Add show_invalid_variations_notice filter to hide the invalid variations notice. 2019-10-30 15:17:31 +02:00
vedanshujain 3c7e74f72d Return early when diff is 0.
Earlier we were also update  `_reduced_stock` meta everytime, but we don't need to when diff is 0 because this means that everything is already consistent.
2019-10-02 17:24:16 +05:30
vedanshujain d2d0bf8466 Also consider refunded item quantity while increasing stock.
When updating an order, we call `wc_maybe_adjust_line_item_product_stock` to see if any item stock needs adjusting. We were not considering if an item has been refunded, which was causing incorrect stock adjustments.
This fix also takes in to account that an order has been refunded partially or fully.

Fixes #24489
2019-10-02 13:42:19 +05:30
Claudio Sanches 1e6785f758 Introduced filter to prevent adjust product stock 2019-07-31 17:37:33 -03:00
Gerhard 8a972ee5c3 Add check for empty string when checking meta_value since checking an empty string in mysql against an int results in a 0 value. 2019-07-03 12:37:28 +02:00
Mike Jolley 9907a25ff6 Append notice if variations are invalid 2019-03-25 13:30:04 +00:00
Mike Jolley 5bb5ae6265 Update from master 2019-02-18 16:54:24 +00:00
Mike Jolley ad12ddd2c2 wc_maybe_adjust_line_item_product_stock should return false if nothing happens 2019-02-18 16:45:55 +00:00
Mike Jolley db0850a420 wc_maybe_adjust_line_item_product_stock helper 2019-01-03 13:40:22 +00:00
Claudio Sanches ff762609e9 Fix how generate pages 2018-11-19 14:25:06 -02:00
claudiulodro 91d2411aa9 Use wc_check_utf8 function 2018-10-05 15:58:50 -04:00
claudiulodro dfad1306de Revert sanitization function used for order item data 2018-10-05 15:46:49 -04:00
Peter Fabian 925002bc37 Changed wc_clean sanitization to checking for valid utf8 and the input is later sanitized by WordPress db layer.
It caused issues in 2 places: Order item name (product name) and user's password.
2018-08-06 20:49:27 +02:00
dezio1900 ac52ce4bad
Update wc-admin-functions.php 2018-06-28 16:31:03 +02:00
dezio1900 cb2980596c
Update wc-admin-functions.php 2018-06-11 20:56:40 +02:00
dezio1900 007fc6e0ca
Allow items to be changed in wc_save_order_items function
Allow other plugins to be able to change $item object, for example to adjust line subtotal/total before its saved. 

My need for this change is because I have custom booking product item, and attached custom inputs for the item ( checkin / checkout dates etc ). So whenever those inputs are changed in order edit page and ajax save is triggered, I need to auto adjust booking item's line subtotal/total ( because of booking dates changed ) before item is saved.
2018-06-11 20:27:32 +02:00
Rodrigo Primo 23b69eba53 Use phpcbf to fix coding standard violations in includes/admin
After using phpcbf to fix the coding standard violations, I did some manual adjustments to the changes, especially in poorly indented files.
2018-03-05 16:21:35 -03:00
Claudio Sanches ef393b8405
Merge pull request #18918 from woocommerce/fix/order-item-meta-key-maxlength
Set maxlength for order item meta key
2018-02-20 16:52:35 -03:00
Mike Jolley 65278efd44 Allow modal to be wider and fix button wrapping 2018-02-15 12:46:47 +00:00
Caleb Burks ea9f799ec6 Remove strlen() condition
Did some tests, substr() is actually faster than the strlen() check.
2018-02-12 17:39:33 -05:00
Caleb Burks 4f447ea48d Sanitize order item meta key w/ max characters 2018-02-09 22:52:36 -05:00
Mike Jolley 29fed057af Mobile styling 2017-11-22 16:28:11 +00:00
Mike Jolley 830ef8ed73 Change status action buttons 2017-11-20 22:43:37 +00:00
Mike Jolley fb446e6bdf Add wp_unslash to meta key 2017-11-07 20:23:10 +00:00
Mike Jolley 804feb9333 Store fee amount and prevent totals going negative 2017-08-23 12:15:06 +01:00
Mike Jolley 2accbdbd45 Load order after updating items 2017-08-11 16:16:22 +01:00
Mike Jolley 532ddfa6b0 Merge conflicts 2017-05-31 12:23:52 +01:00
Mike Jolley c3c966b5fd Add handles so drag and drop does not break edit on mobile
Fixes #15118
2017-05-18 15:22:12 +01:00
Mike Jolley d67fb8fb83 New style import controller
Closes #15107
2017-05-17 14:16:38 +01:00
Mike Jolley 523d9d27cd Styling 2017-05-12 20:40:54 +01:00
Mike Jolley fd3bf05017 Working prototype exporter for products 2017-05-10 17:22:08 +01:00
Claudio Sanches af7f271de1 Fixed sanitization of order items meta data
Closes #14067
2017-04-06 17:58:24 -03:00
Mike Jolley bbf8e750ce Tidy up includes 2017-02-16 11:46:01 +00:00
Mike Jolley cf59524dd7 Fix order total race condition in CRUD 2016-09-07 09:28:11 +01:00
Aristeides Stathopoulos ec8a0b288b PHPCS: WordPress.Arrays.ArrayDeclaration.NoCommaAfterLast 2016-08-27 05:08:49 +03:00
Aristeides Stathopoulos b063bcfe4c last item in a multiline-array should end in a comma 2016-08-27 04:46:45 +03:00
Mike Jolley 627b08ba37 Test coverage 2016-08-25 17:42:47 +01:00
Mike Jolley 885231baba yoda 2016-08-25 17:10:59 +01:00
Mike Jolley 7f87800d8d Fix save order item function 2016-08-25 13:50:37 +01:00
Mike Jolley 25883f8687 Set_props helper to load data from DB and handle errors 2016-08-25 13:05:27 +01:00
Mike Jolley 26c4b3ce13 Delete if qty = 0 2016-08-24 16:09:39 +01:00