public async Task <WooCommerceProduct> UpdateProductQuantityAsync(int productId, int quantity) { var updateProductRequest = new WLegacyApi.Product() { id = productId, stock_quantity = quantity }; await this._legacyApiWCObject.UpdateProduct(productId, updateProductRequest); return(updateProductRequest.ToSvProduct()); }
public static WooCommerceProduct ToSvProduct(this WooCommerceNET.WooCommerce.Legacy.Product legacyProduct) { return(new WooCommerceProduct() { Id = legacyProduct.id, Sku = legacyProduct.sku, Name = legacyProduct.title, Description = legacyProduct.description, ShortDescription = legacyProduct.short_description, Price = legacyProduct.price, Quantity = legacyProduct.stock_quantity, Categories = legacyProduct.categories?.Select(c => c.ToString()), Images = legacyProduct.images?.Select(i => i.src), Weight = legacyProduct.weight?.ToDecimal(), SalePrice = legacyProduct.sale_price, RegularPrice = legacyProduct.regular_price, Attributes = legacyProduct.attributes?.ToAttributeDictionary(), Variations = legacyProduct.variations?.Select(v => v.ToSvVariation()), HasVariations = legacyProduct.variations != null && legacyProduct.variations.Any(), CreatedDateUtc = legacyProduct.created_at, UpdatedDateUtc = legacyProduct.updated_at, ManagingStock = legacyProduct.managing_stock }); }