So when im adding a new orderline im updating the unit price if the product is part of a campaign, its quite simple and looks like this :
private void WebshopEvents_OrderLineAdded(Order order, OrderLine Orderline)
{
var campaignItem = new CampaignHandler().hasCampaign(Orderline.NodeId);
if (campaignItem.HasCampaign)
{
var calcedPrice = Convert.ToInt32(Orderline.UnitPrice);
calcedPrice = calcedPrice = Convert.ToInt32(calcedPrice - Convert.ToDouble((campaignItem.Percentage / 100.0) * calcedPrice));
order.OrderLines.First(x => x.Id == Orderline.Id).UnitPrice = calcedPrice;
order.Save(); //<---- After Save it runs Here it runs the OrderLineChanged event and the price of the order is correct.
}
} //<---- when the current event ends here it runs the OrderLineChanged again but this time the price of the order is back to square one.
The problem is in the 2 comments.
The OrderLineChanged event is not doing anything to the price.
Actually i cannot answer you that because i cannot find anything in the database besides the orderline price and that dosnt change.
So this is what happens :
Right after i hit .Save() it goes into "OrderLineChanged"(Recalculateprice) and the total orderprice is 869 like it should be.
So so far all looks good. Nothing actually happens in the recalculate method since it only does recalculation of the price when a giftcard is added.
Next it returns to the "orderlineadded", and finishes it off still everything is good.
Apperently when it finished the "orderlineadded" event it then goes back down into the "OrderLineChanged" event, and here the total order price changes :
In the database the orderline unit price keeps on 999 and does not change to 809 as expected.
When you check the database you should look for the column - ManipulatedUnitPriceWithoutVAT which is the one that is being saved - the unit price will always be the one from Umbraco when the order line was added.
The reason why the order line updated event is triggered is because you save the order in the order line added event. It is correct to call order.Save() but it was just to let you know that this behavier is expected. Ofcourse the pricing stuff isnt expected :)
Will have a look at the ManipulatedUnitPriceWithoutVAT then :)
Yea i was expecting the OrderLineChanged event to be fired aswell.
So ive checked the manipulated and it does actually change, but as soon as the event is finished it changes again. But its not something i can step into.
the price is changed :
and when the event ends and it continues to "OrderLineChanged" once more it changes back:
Could you try and simplify your events so you only have one event and that is the order line added event. Then just change it and save the order - no other code. Then see if that works. If it does you have to look somewhere else of how this price can be changed.
So RIGHT after the order.Save method has run - before your code quits the event. Try and check the database and see what the ManipulatedUnitPriceWithoutVAT is. Is that the value that you had set?
Teacommerce events and order save not playing nicely
Hey there
Again its a TC 1 case, sorry :)
In this shop im hooking in to a few events :
So when im adding a new orderline im updating the unit price if the product is part of a campaign, its quite simple and looks like this :
The problem is in the 2 comments.
The OrderLineChanged event is not doing anything to the price.
So is it saved correctly do the DB right after the first order.Save()?
Kind regards
Anders
Actually i cannot answer you that because i cannot find anything in the database besides the orderline price and that dosnt change.
So this is what happens :
Right after i hit .Save() it goes into "OrderLineChanged"(Recalculateprice) and the total orderprice is 869 like it should be.
So so far all looks good. Nothing actually happens in the recalculate method since it only does recalculation of the price when a giftcard is added.
Next it returns to the "orderlineadded", and finishes it off still everything is good.
Apperently when it finished the "orderlineadded" event it then goes back down into the "OrderLineChanged" event, and here the total order price changes :
In the database the orderline unit price keeps on 999 and does not change to 809 as expected.
When you check the database you should look for the column - ManipulatedUnitPriceWithoutVAT which is the one that is being saved - the unit price will always be the one from Umbraco when the order line was added.
The reason why the order line updated event is triggered is because you save the order in the order line added event. It is correct to call order.Save() but it was just to let you know that this behavier is expected. Ofcourse the pricing stuff isnt expected :)
Will have a look at the ManipulatedUnitPriceWithoutVAT then :)
Yea i was expecting the OrderLineChanged event to be fired aswell.
So ive checked the manipulated and it does actually change, but as soon as the event is finished it changes again. But its not something i can step into.
the price is changed :
and when the event ends and it continues to "OrderLineChanged" once more it changes back :
Could you try and simplify your events so you only have one event and that is the order line added event. Then just change it and save the order - no other code. Then see if that works. If it does you have to look somewhere else of how this price can be changed.
Kind regards
Anders
Hey Anders
http://www.screenr.com/d2wH
Ive made a quick screener where you can see that all other events are disabled, and that the event runs fine through.
but still when i look up the order right after it still looks like this :
So RIGHT after the order.Save method has run - before your code quits the event. Try and check the database and see what the ManipulatedUnitPriceWithoutVAT is. Is that the value that you had set?
The field is null when im entering the method.
Right after .save (the method is not finished) the value is set to 647,20 (correct).
The method ends and its set to 799.20 again.
Im not doing anything in either on the page your landing on or through JS just double checked.
If you have 5 could you skype me ? you have me added :)
is working on a reply...