On a SalesOrderRow there’s a enum property called ProductType that can have a value of PhysicalGoods, DigitalGoods, Service or Unknown.
When a product is added to the cart the ProductType value seems to be automatically set to PhysicalGoods. What is that based on? How can make it so it’ll be set to DigitalGoods for some products?
Is there any documentation over how the ProductType property is supposed to be used? For example if an order is placed that has both rows that are PhysicalGoods and rows that are DigitalGoods the order should probably have two shipments. Is Litium handling this automatically or do we need to code that ourselves?
When looking at SalesOrderRowFactory it looks pretty hard coded.
ProductType = ProductType.PhysicalGood
Perhaps a feature that will come later on?
But it looks like it can be updated after it’s been added by modifying the order row on the cart.
I have done simillar with this:
// Not official Litium api, could change at any time.
var context = HttpContext.GetCartContext();
var _ = _cartContextSessionService.UpdateAsync(context.Cart.SystemId, cartContextSession =>
{
cartContextSession.Cart.Order.Rows //Update row.
return Task.FromResult(true);
}, CancellationToken.None)?.Result;
The product type is today hard coded to physical goods but can be overrided if you either decorate or implement your own Litium.Sales.Factory.ISalesOrderRowFactory. This is today needed if you sell digital goods, example books, that are delivered directly when the confirmation happen. This is used by the payment provider to better handle claims or refund request of the digital delivered products.
Regarding shipments you decided if the product will go into one or multiple shipments when the shipment is created.
Thanks! Sounds like the right way for us to go then, as we sell digitally delivered software and hardware that can be placed on the same order.
A decorator seems like a good way to do this. What would be the preferred way to update the sales order row in the decorator after _parent.Create(args); has run? Is it what @Ericsj11 suggests above?
Either update the row in the decorator after the _parent.... is executed or if you select to implement your own SalesOrderRowFactory without decorating the default one.
Using the CartContextSessionService as @Ericsj11 is not a solution that I can recommend because of:
It’s not part of Litium official API and may be changed without notice.
It’s internal low-level API inside the plattform and you need to know what other methods that you need to chain the calls with.
It’s to easy to mess things up and get other problems because something is changed that shouldn’t been changed.