XiaoFaye / WooCommerce.NET

A .NET Wrapper for WooCommerce/WordPress REST API
MIT License
391 stars 217 forks source link

Using an ID when creating Variation Attribute (or anything really) doesn't work #771

Open dmainmon opened 7 months ago

dmainmon commented 7 months ago
          I think you need to pass attribute ID in vatrib.

Originally posted by @XiaoFaye in https://github.com/XiaoFaye/WooCommerce.NET/issues/436#issuecomment-596412473

I think you need to pass attribute ID in vatrib.

Anytime I specify an id when adding a Variation Attribute (or anything really), nothing gets added. If I use 0 or omit the id, It gets added. The code below doesn't work (no error message, just doesn't add the Variation Attribute).

Variation newVariation = variant;
newVariation.attributes = new List<VariationAttribute>()
 {
      new VariationAttribute()
       {            
            id=99,          // THIS DOES NOT WORK          
           name="Options",
           option= Variants[count]
       }
 };
 var upVar = wc.Product.Variations.Update((ulong)variant.id, newVariation, Convert.ToUInt32(RecID));

The next section code adds works but there's no id or it's 0. Anything else and it never get's added.

Variation newVariation = variant;
newVariation.attributes = new List<VariationAttribute>()
 {
      new VariationAttribute()
       {                                
           name="Options",
           option= Variants[count]
       }
 };
 var upVar = wc.Product.Variations.Update((ulong)variant.id, newVariation, Convert.ToUInt32(RecID));
keesmeel commented 4 days ago

We have the same issue