So im hooked into the CalculatePrice event, and in here there is a special case where i want to add an extra orderline. The orderline can have a shifting name and price, so i cannot just create a node with a fixed price and add that.
But cannot get anything to work.
Im trying this :
Dictionary<string, string> props = new Dictionary<string, string>();
props.Add("uniqueId",Guid.NewGuid().ToString());
var ol = order.OrderLines.AddOrUpdate(orderLine.ProductIdentifier, 1, props);
ol.UnitPrice = new PriceInformation() { Value = new Price(price, orderLine.VatRate, currency) };
ol.Name = "WeekendTillæg";
Should it maybe be an award instead of doing it in the calculator?
But you need to create your own order line and not use the order.OrderLines.AddOrUpdate as it use Umbraco to add the order line. You will have to create an order line totally manual.
well i dont think we can clarify it as an award and there are so many "properties" that needs to be fulfilled for this to happen though.
Its because the product ordered has a date within a weekend and the customer needs to pay the weekend extra fee, and the fee is based on the amount of people.
Could you give an example of what is minimum for creating an orderline from scratch ?
Add orderline from C# in v3
Ey :)
So im hooked into the CalculatePrice event, and in here there is a special case where i want to add an extra orderline. The orderline can have a shifting name and price, so i cannot just create a node with a fixed price and add that.
But cannot get anything to work. Im trying this :
Should it maybe be an award instead of doing it in the calculator? But you need to create your own order line and not use the order.OrderLines.AddOrUpdate as it use Umbraco to add the order line. You will have to create an order line totally manual.
well i dont think we can clarify it as an award and there are so many "properties" that needs to be fulfilled for this to happen though.
Its because the product ordered has a date within a weekend and the customer needs to pay the weekend extra fee, and the fee is based on the amount of people.
Could you give an example of what is minimum for creating an orderline from scratch ?
See the GetSnapshot of the Umbraco InformationExtractor at Github - that is what is used to get info from the product and then the quantity.
https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/blob/master/Source/TeaCommerce.Umbraco.Configuration/InformationExtractors/XmlNodeProductInformationExtractor.cs
awesome ill look into it.
Hey Anders
I really can't figure out how to create an orderline manually, could you make an a small example that would really help.
OrderLine orderLine = new OrderLine();
orderLine.Sku = "1000";
orderLine.ProductIdentifier = "1000";
orderLine.Name = "Test product";
orderLine.Quantity = 1;
orderLine.OriginalUnitPrices.Add(new OriginalUnitPrice(995.95M, 1)); //1 is the currencyId
orderLine.Properties.Add("test", "value");
order.OrderLines.Add(orderLine);
order.Save()
Awesome man !
Its working :)
is working on a reply...