Create a webhook programmatically in wordpress/woocommerce
-
i’m making a Plugin to make a integration of one ERP to Woocommerce and i’m thinking about using the web hooks for that integration, the problem create the web hooks when the plugin is activated for the first time, and not oblige people to create the woocommerce webhooks manually and configure them. i googled and tried several things but looks like no one works, also tried make a sql query, but don’t worked.
i tried this:
class Store_Webhook_Endpoints{ public function createWebhook(){ $user_id = array('1','2','3'); $topic = array('order.created','customer.created','product.created'); for ($i=0; $i < count($topic) ; $i++) { $webhook = new WC_Webhook(); $webhook->set_user_id( $user_id[$i] ); // User ID used while generating the webhook payload. $webhook->set_topic( $topic[$i] ); // Event used to trigger a webhook. $webhook->set_secret( 'secret' ); // Secret to validate webhook when received. $webhook->set_delivery_url( 'https://webhook-handler.com' ); // URL where webhook should be sent. $webhook->set_status( 'active' ); // Webhook status. $webhook->save(); } } }
but isn’t work that
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Create a webhook programmatically in wordpress/woocommerce’ is closed to new replies.