-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Prevent "woocommerce_new_order" from being triggered on orders with "checkout-draft" status #47422
base: trunk
Are you sure you want to change the base?
Prevent "woocommerce_new_order" from being triggered on orders with "checkout-draft" status #47422
Conversation
…checkout-draft" status
Hi @opr, @senadir, @vedanshujain, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow this, there's no consideration for status strings on the linked example (create order), and the new order action seems to be triggered disregarding the status. For the other example (since one has a broken link, and there's no referenced lines if I try to fix it), I agree with you, it is not considering moving the order from Can you please elaborate on the other two Nadir? Thanks in advance :) |
…checkout-draft" status
…w order action for order creation
…gers-on-checkout-visiting' into 45145-woocommerce_new_order-triggers-on-checkout-visiting
…ommerce/components, woocommerce-blocks, woocommerce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wavvves I think what @senadir is referring to here is we would want two separate changes:
- Not trigger the
woocommerce_new_order
hook when the status is one of the draft ones. You are already doing this for HPOS but not for CPT. - Do trigger this hook, when the status is changed from a draft one to a non draft one. You are doing this for CPT but not for HPOS.
Essentially, we should:
- Prevent triggering this hook for CPT when status is draft. See https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php#L103C15-L103C24
- Prevent triggering this hook for HPOS when status is draft. (You are already doing this)
- Trigger this hook when status is changed from draft to non draft for CPT. (You are already doing this).
- Trigger this hook when status is changed from draft to non draft for HPOS. See https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php#L2626.
Additionally, we should probably make the list of draft statuses consistent, plus maybe add some unit tests around these flows. wdyt?
Yeah that's exactly what I had in mind @vedanshujain , just more elegantly from your side |
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR prevents "woocommerce_new_order" action from being triggered when visiting the Checkout Block page, while the order status is "checkout-draft".
Closes #45145 .
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Changelog entry
Significance
Type
Message
Prevent "woocommerce_new_order" from being triggered on orders with "checkout-draft" status
Comment