Developer forum

Forum » Development » Get AvailableAmount via API

Get AvailableAmount via API

Vincent Gercke Pedersen
Reply

Hi,

Is there any way to access the AvailableAmount (TT: Ecom:Product.AvailableAmount) via the API?

Kind regards,
Vincent


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Vincent

Try something like this:

Dynamicweb.Ecommerce.Products.Product product = Ecommerce.Services.Products.GetProductById("PROD1", "VariantID", "Lang1");
string unitid = "unit1";
Stocks.StockLocation stocklocation = Ecommerce.Services.StockService.GetStockLocation("location1");
double reservedStock = Dynamicweb.Ecommerce.Frontend.Cart.ProductReserve.GetReservedAmount(product.Id, product.VariantId);
double unitStock = product.GetUnitStock(stocklocation, unitid);
double availableAmount = unitStock - reservedStock;

BR Nicolai

Votes for this answer: 1
 
Vincent Gercke Pedersen
Reply

Thanks!

 

You must be logged in to post in the forum