-
Notifications
You must be signed in to change notification settings - Fork 843
Jetpack Sync: Only sync woocommerce_update_order_item for changed items #46148
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
…t test / consumer issues
Fixes SYNC-174
Proposed changes:
woocommerce_update_order_itemfrom being synced multiple times per order, for orders with multiple items, when only one item is being updated.What we are doing:
woocommerce_before_order_item_object_saveget_changesfor this. One downside is that this doesn't record changes unless meta is changed via the object API. As such, we now have additional hooked functions (hooked intoadded_order_item_metaandupdated_order_item_meta), which are simply recording if meta has been added or updated in any other way, such as via the UI.woocommerce_update_order_itemwhen we didn’t record any actual item changesOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
To test, create a JN site with Jetpack and WooCommerce installed and active. Then on trunk (bleeding edge or release candidate):
wpshconfirm the order item and order item meta details for one item are synced:gpr select * from wp_{BLOGID}_woocommerce_order_items where order_item_id={ID}andgpr select * from wp_{BLOGID}_woocommerce_order_itemmeta where order_item_id={ID}updated_order_item_metafor the order (object) item id in question, 1woocommerce_update_order_itemfor every item in the order (in this case should be 5), 1woocommerce_after_order_object_savewpsh, confirm the order item and order item meta details for the same item are correct (the item meta_line_totalshould be the only thing to change).wpsh, check other items and item meta in that order, to confirm nothing else has changed.woocommerce_update_order_itemfor every item in the order (in this case should be 5), and 1woocommerce_after_order_object_save, being synced.For changes that affect multiple items:
woocommerce_after_order_object_savebeing synced.updated_order_item_metaandwoocommerce_update_order_itemactions firing for each item id.To test the changes, apply this PR using the Jetpack Beta tester plugin, then:
updated_order_item_metafor the order (object) item id in question, 1woocommerce_update_order_itemfor the same item id, 1woocommerce_after_order_object_savewpshas before, the results should be as expected.wpshthat changes are reflected.The above tests assume testing with HPOS enabled, but the same applies for legacy order data storage.