Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

woocommerce_blocks_checkout_update_order_from_request doesn't trigger for customer email. #5202

Closed
senadir opened this issue Nov 19, 2021 · 3 comments · Fixed by #5345
Closed
Assignees
Labels
type: bug The issue/PR concerns a confirmed bug.

Comments

@senadir
Copy link
Member

senadir commented Nov 19, 2021

I'm not sure if this was planned or not, but woocommerce_blocks_checkout_update_order_from_request only triggers when order updates, this means all hits to store/checkout would trigger it, however, store/update-customer (what we use when persisting the customer email) isn't part of that, and so woocommerce_blocks_checkout_update_order_from_request won't run.

A workaround for that is to use woocommerce_before_order_object_save hook.

See #5179 (comment)

@mikejolley is this expected behavior? I would probably move email updates to happen in store/checkout to solve this maybe.

@senadir senadir added the type: bug The issue/PR concerns a confirmed bug. label Nov 19, 2021
@mikejolley
Copy link
Member

woocommerce_before_order_object_save will run outside of the context of store API. Potentially needs a new hook or we can implement the current one, although naming might be problematic.

I would probably move email updates to happen in store/checkout to solve this maybe.

Yeah that might be a good solution. We should be able to accept updates via the checkout endpoint.

@mikejolley mikejolley self-assigned this Dec 6, 2021
@mikejolley
Copy link
Member

@senadir Does this comment mean this is no longer needed for the use case you referenced?

woocommerce_blocks_checkout_update_order_from_request action provides the draft order, and the request data from the checkout route request. This data sent to the checkout endpoint will differ from that sent to other endpoints such as cart/update-customer.

Additionally, maybe_update_order in the cart endpoint does not process request data at all. It syncs the draft order with the customer object. So reimplementing this hook at this point does not make much sense to me.

It would be nice to have some consistent hooks between the endpoints so developers can grab request data and do something to draft orders, or the cart, so I will try to implement that. But I won't be moving the hook we have now.

@senadir
Copy link
Member Author

senadir commented Dec 6, 2021

I'm assuming the need to react to the email being filled is going to come back later (express payment methods that checks the email, newsletters) so we might need to provide something better than woocommerce_before_order_object_save.

woocommerce_blocks_checkout_update_order_from_request action provides the draft order, and the request data from the checkout route request. This data sent to the checkout endpoint will differ from that sent to other endpoints such as cart/update-customer.

I agree with the rest of your points. Moving email to store/checkout also sounds good but the benefits aren't that big now unless we're okay running woocommerce_blocks_checkout_update_order_from_request several times and sending checkoutExtensionData which each update. It's hard to decide if developers:

  • Expect whatever they do to always persist (but then, when would it persist?).
  • For it to only persist once you hit place order.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants