Hello
I am looking into Umbraco Commerce and doing some prototyping. One of our requirements is that we will have products as nodes, and products from external sources.
From what I can read, I should be able to create a custom ProductSnapShot that inherits from IProductSnapshotWithImage, and add that to my order. Everything also looks fine except the price gets saved as 0.
Help would be greatly appreciated
I have based the following code on
https://github.com/umbraco/Umbraco.Commerce.DemoStore
public IActionResult AddToCart(AddToCartDto postModel)
{
var store = CurrentPage.GetStore();
var currencyGuid = _currencyService.GetCurrency(store.Id, "GBP");
var name = "Test Product";
var productPrices = new List
{ new ProductPrice(50, currencyGuid.Id) };
var imageUrl = "https://localhost:44322/media/dksp5tpr/test-3.jpg?width=500&height=500&v=1d885613f9a7f59";
var sku = "sku-123";
var externalProductSnapShot = new ExternalProductSnapShot(store.Id, name, productPrices, imageUrl, sku);
_commerceApi.Uow.Execute(uow =>
{
var order = _commerceApi.GetOrCreateCurrentOrder(store.Id)
.AsWritable(uow)
.AddProduct(externalProductSnapShot, 1);
_commerceApi.SaveOrder(order);
uow.Complete();
});
return CurrentUmbracoPage();
}