I'm working on woocommerce project and I need to check inventory status via external API before I create order. It is a cash register system in physical store that I can't change. I'm using
woocommerce_checkout_order_processed
hook to add my logic here but I'm not sure how can I prevent order from saving if invenotry over API changed in meantime. So the flow I need here is:
- User wants to buy 10 items, adds them to cart
- User clicks 'Place Order'
- hook is activated
- api is triggered and it returns that only 5 are available at the moment
- show message and don't save order