Can I use the combination of webhook and Order admin API to block an order to be completed?

I am working on a client store. I added a function of allowing customers to select delivery date, which is stored in the cart note attributes. The delivery date must be at least next day (never the current day) or in the future.

To avoid the scenarios that a customer chooses a delivery date, and then comes back a few days later to continue shopping, I added validations in the cart page to make sure the delivery date is at least next day. That works fine if the customer has to go back to the cart page where the validation is.

So there is a problem in the following scenario:

  • On day 1, a customer chooses the delivery date to be day 2. He passes the cart and starts checking out, but he leaves the page open without finishing it. (This is more common on mobile phones. For example, you get disrupted by a message and then forget to come back to finish.)
  • On day 2, the customer comes back to the browser and continues the checkout process on that already opened page. So at this point, the selected delivery date day 2 is not valid any more.

Technically, is it possible to use the combination of Checkout webhook and Order admin API to block an order to be completed? I could not find a more detailed explanation when the webhooks are triggered in the process of an order.

I think what I really need is to be able to inject a validation just before the order payment is completed. The current validation position in cart is still a little early even though it captures most cases.

Any other ideas will be warmly welcomed. Thanks in advance.

Hi Rocksoccer,

The simplest solution for your problem is, instead of having them to select the date of delivery. Just put a select element with options like the following:

  1. Delivery +1 day after order is paid
  2. Delivery +2 day after order is paid
  3. Delivery +3 day after order is paid
  4. … and so on

And the above is saved to your note attributes, feel free to modify the above options as per your needs. Then when the customer pays for an order. Just check the order paid date in the admin and then update/add an appropriate note attribute.

Basically there are various solution to your problem.

If you need help, feel free to PM me.

Thanks.

Unfortunately, the exact date is a very high priority business requirement because the store sells fresh food to be delivered for special occasions. Using relative date affecting the user experience significantly.

Any other suggestions?