• Resolved tharindu1995

    (@tharindu1995)


    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)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create a webhook programmatically in wordpress/woocommerce’ is closed to new replies.