Adding product variations with multiple attributes Adding product variations with multiple attributes wordpress wordpress

Adding product variations with multiple attributes


Create the product. Create the variation with the product id.

Product p = new Product(){    //options ....    type = "variable",    manage_stock = true,   in_stock = true,    attributes=attribs,    //variations=varis,};//Returns the new product with the id.p = await wc.Product.Add(p);//Returns the new variation with the idvar1 = wc.Product.Variations.Add(var1, p.id.Value);// Add the variation id to the productp.Variations.Add(var1.id.Value);//Update the productwc.Product.Update(p.id.Value, p);