Developer forum

Forum » Development » How to set new Order.TotalPrice

How to set new Order.TotalPrice

Martin Nielsen
Reply
Hi DW,

I have an OrderlineExtender where I set the unitprice of my orderline.

For instance:
  base.OrderLine.SetUnitPrice( base.OrderLine.Price.Price * 0.8 );

Doing this doens't update the calculation of the order total.

Should i be updating the price somewhere else? Or do i need to change more SetUnitPrice?

// Martin

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer
Hi Martin

You are correct, this is due to internal price caching in the Order object. I have created an item in our backlog for this, and it should be out in the next service release.

In the meantime, you can use the code in my next post as a workaround until the permanent fix is in. It utilizes a property on the Order class called AllowOverridePrices, but I would only recommend this as a temporary fix because you have to add fees to the price manually.
 
You can read more about AllowOverridePrices here: http://developer.dynamicweb-cms.com/forum/development/override-prices-on-orderlines.aspx

Hope this helps :)

- Jeppe
Votes for this answer: 0
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
base.OrderLine.SetUnitPrice(base.OrderLine.Price.Price * 0.5);

var price = base.Order.PriceBeforeFees.Add(base.Order.PaymentFee).Add(base.Order.ShippingFee);

base.Order.AllowOverridePrices = true;
base.Order.Price.PriceWithoutVAT = price.PriceWithoutVAT;
base.Order.Price.PriceWithVAT = price.PriceWithVAT;
base.Order.Price.VAT = price.VAT;

 

You must be logged in to post in the forum