Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wc_maybe_adjust_line_item_product_stock() #337

Closed
magenta-cuda opened this issue Sep 14, 2021 · 1 comment
Closed

wc_maybe_adjust_line_item_product_stock() #337

magenta-cuda opened this issue Sep 14, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@magenta-cuda
Copy link

magenta-cuda commented Sep 14, 2021

WooCommerce now has a function wc_maybe_adjust_line_item_product_stock() defined in wc-admin-functions.php to adjust stock quantity when an order item is deleted. This function is called by wc_save_order_items() and WC_AJAX::remove_order_item(). You may want to add this function and its calls to ClassicCommerce.

N.B. The function wc_maybe_adjust_line_item_product_stock() use the data base field '_restock_refunded_items' of table $wpdb->prefix . 'woocommerce_order_items'. This data base field did not exists for order version less than 5.5. However, it can be created using the function WC_Order::get_qty_refunded_for_item(). (See RestockRefundedItemsAdjuster::initialize_restock_refunded_items())

N.B. I think when this featured was first introduced into WooCommerce it may have also introduced a bug. See issue woocommerce/woocommerce#29502. I checked and this bug does not exists in ClassicCommerce 1.0.4. So, it was introduced sometime later, maybe by the introduction of this feature. So some care should be taken implementing this.

@ghost ghost added the enhancement New feature or request label Sep 14, 2021
@ghost
Copy link

ghost commented Sep 14, 2021

Thanks for this. Sounds like a useful addition.

wc_maybe_adjust_line_item_product_stock() WC 3.6.0
Sees if line item stock has already reduced stock, and whether those values need adjusting e.g. after changing item qty.

We are a little short on developers at the moment but will keep it in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant