
From WooCommerce Product Save to 'Add to Cart' in a Chat Conversation
A store owner saves a product in WooCommerce. Three seconds later, a customer on the other side of the world finds that product by typing "something warm for winter" into a chat widget, adds it to their cart, and checks out. The store owner sees the purchase attributed to the chat session on their dashboard. That's a lot of systems talking to each other. Here's what happens at each step. Step 1: Product Save Triggers a Webhook The WooCommerce plugin hooks into woocommerce_update_product . When the store owner clicks "Publish" or "Update," the hook fires and queues a webhook event in memory. The event isn't sent immediately. It goes into an in-memory queue that flushes on WordPress's shutdown action, after the HTTP response is already sent to the browser. The admin page loads at normal speed. The webhook happens a fraction of a second later. // Simplified from the actual plugin add_action ( 'woocommerce_update_product' , [ $this , 'on_product_update' ]); add_action ( 'shutdown' , [ $thi
Continue reading on Dev.to Webdev
Opens in a new tab




