I use the WoocommerceNET library ( Nuget Link ) to develop a desktop application that will synchronize products from the ERP database with the Woocommerce eshop database.
I added size and color attributes with values ββlike red, green, blue and s, m, l, xl. Now I need to create a variation.
Tried this:
List<VariationAttribute> vatrib = new List<VariationAttribute>()
{ new VariationAttribute() { name="Color",option="GREEN" },
new VariationAttribute() { name="size",option="L" } };
Variation var = new Variation() {
regular_price=1.0M,
visible=true,
attributes=vatrib,
stock_quantity=5,
manage_stock=true
};
List<Variation> varis = new List<Variation>();
varis.Add(var);
varis.Add(var1);
varis.Add(var2); ... and so on for all variations
Product p = new Product()
{
type = "variable",
manage_stock = true,
in_stock = true,
attributes=attribs,
variations=varis,
};
await wc.Product.Add(p);
But I get an error
It is not possible to implicitly convert the type 'System.Collections.Generic.List <WooCommerceNET.WooCommerce.v2.Variation>' to 'System.Collections.Generic.List <int>'
It looks like the variant attribute for the product is a list containing the variant identifiers.
?