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

Do not call save() when processing order item #185

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

mntzrr
Copy link
Collaborator

@mntzrr mntzrr commented Jul 18, 2024

Calling save() causes the order ID to return 0 (or sometimes null) in the woocommerce_new_order_item action hook if the priority is too low. This has caused a compatibility issue with plugins that rely on the order ID to be available.

Since the save() is not necessary when processing order items (it is however required for orders), we can safely remove it.

Furthermore, we don't need to call update_meta_data since the order line is only added once. Instead add_meta_data suffices.

Tested w/wo HPOS.

https://app.clickup.com/t/86955260q

Calling save() causes the order ID to return 0 (or sometimes `null`) in the `woocommerce_new_order_item` action hook if the priority is too low. This has caused a compatibility issue with plugins that rely on the order ID to be available.

Since the save() is not necessary when processing order items (it is however required for orders), we can safely remove it.

Furthermore, we don't need to call `update_meta_data` since the order line is only added once. Instead `add_meta_data` suffices.

Tested w/wo HPOS.
@mntzrr mntzrr requested a review from NiklasHogefjord July 18, 2024 13:41
@mntzrr mntzrr self-assigned this Jul 18, 2024
@mntzrr mntzrr requested review from MichaelBengtsson and removed request for NiklasHogefjord July 19, 2024 09:09
@MichaelBengtsson MichaelBengtsson merged commit 63e1313 into develop Aug 14, 2024
@MichaelBengtsson MichaelBengtsson deleted the develop-compat-new-order-item branch August 14, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants