Question

How to use webhook to create product variations in WooCommerce?

  • 9 February 2022
  • 3 replies
  • 299 views

Hey, 

 

I’m trying to create a webhook to post to my Woocommerce site. Since the ids are automatically generated after a new item is added, what do I need to enter in the ID fields, since they are required?

 

Example: This is not the full code…. 

 

{

"id": , // What to enter here?

"date_created": "",

"date_created_gmt": "",

"date_modified": "",

"date_modified_gmt": "",

"description": "",

"permalink": "",

"sku": "21. Sku:139004",

"price": "",

"regular_price": "21. Price:20.00",


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +14

@Shakila_Reed 

Seems like you’d first need to create a Product, then second create the Variation(s).

I’m using the create variations end point. post > /wp-json/wc/v3/products/<product_id>/variations 

 

https://woocommerce.github.io/woocommerce-rest-api-docs/?php#product-variation-properties

 

I am able to successfully upload the sku and regular price, with webhook > post. Doing it that way, Zapier automatically generates this information. But since I have nested data, i have to use the custom request. 

Userlevel 7
Badge +14

Hi @Shakila_Reed 

What WooCommerce API Endpoint are you trying to use?

Please link to the WC API endpoint documentation you are referencing.