Developer forum
E-mail notifications
Change the amount sent to DIBS
Replies
The amount is part of a checksum sent to DIBS, and if you change amount, checksum will not match and payment will fail.
Is the eCommerce.Order.Steps.Confimed the way to change the amount or is there one BeforeSentToGateway method ?
We use Cart v2 on this posta.fo solution.
Is there an equivalent method for order object like the one on orderline SetUnitPrice() ?
You can set AllowOverridePrices on the order to true stopping the order object from calculating... But you cannot overwrite the .Price priceinfo instance, so that does not help you alot.
So adding an orderline is the only way...
This is my code so far, but it is not working correctly:
public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
{
Dynamicweb.Ecom7.Cart.Notifications.OrderIsPassedToCheckoutHandlerArgs handler =
(Dynamicweb.Ecom7.Cart.Notifications.OrderIsPassedToCheckoutHandlerArgs)args;
Order o = handler.Order;
string cc = Base.ChkString(o.CustomerCountryCode).ToLower().Trim();
LogEvent(o, "Country code for order is: " + cc + " in shop: " + o.ShopID);
if ((cc == "dk" || cc == "fr") && o.ShopID == "SHOP5")
{
if (o.PriceBeforeFees.Price < 80)
{
foreach (OrderLine ol in o.OrderLines)
{
ol.SetUnitPrice(ol.Price.PriceWithoutVAT);
ol.Save();
LogEvent(o, "Update product price for " + ol.ProductName + " to " + ol.Price.Price + " (" + ol.Price.PriceWithoutVAT + ")");
}
o.UpdateVAT(0.0);
o.Save();
}
}
handler.Order = o;
handler.Order.Save();
LogEvent(o, "Order price is updated to " + o.Price.Price);
base.OnNotify(notification, handler);
}
private void LogEvent(Order order, string message)
{
string str2 = string.Format("Order {0}: {1}", order.ID, message);
LogToFile.Log(str2, "/eCom/CartV2/Events", LogToFile.LogType.ManyEntriesPerFile);
if (order != null)
{
order.DebuggingInfos.Add(new Order.DebuggingInfo(str2));
order.SaveDebuggingInfos();
}
}
You should not do like this:
base.OnNotify(notification, handler);
Think that will trigger the notification to be executed again.
The order vat is not set to zero when order price without fees is under 80 kr.
In my code i have tried (loop of products) to set all product prices to without vat prices. This should be removed if i get Update(0.0) to work.
Dynamicweb.Ecom7.Cart.Notifications.OrderIsPassedToCheckoutHandlerArgs handler =
(Dynamicweb.Ecom7.Cart.Notifications.OrderIsPassedToCheckoutHandlerArgs)args;
string cc = Base.ChkString(handler.Order.CustomerCountryCode).ToLower().Trim();
LogEvent(handler.Order, "Country code for order is: " + cc + " in shop: " + handler.Order.ShopID);
if ((cc == "dk" || cc == "fr") && handler.Order.ShopID == "SHOP5")
{
if (handler.Order.PriceBeforeFees.Price < 80)
{
handler.Order.UpdateVAT(0.0);
handler.Order.Save();
}
}
handler.Order.Save();
I have tried to execute sql query (order and orderline objects) for doing the updates, but this does not override the order price, they must be recalculated at a latter stage.
If i read the order log lines there is a line where it updates the price after the OrderIsPassedToCheckoutHandler is called. This is the line:
Order ORDER2194: Order price is updated to 58,6
My order price should be 57,0. How can i change this price to 57,0 ??
You can use AllowOverridePrices to completely control the PriceInfo on the order. Do some like this:
// Assume o is your Order object
if (o.PriceBeforeFees.Price < 80.0)
{
// Set VAT for the Order
o.AllowOverridePrices = true;
o.Price.VAT = 0.0;
// Set VAT for all OrderLines
foreach (Orderline ol in o.Orderlines)
{
ol.AllowOverridePrices = true;
ol.Price.VAT = 0.0;
}
// Save Order
o.Save();
}
The properties AllowOverridePrices were added in 19.2.2.4.
Hope this helps :)
- Jeppe
AllowOverridePrices setting was the flag i was looking for, thx. The last price update is not called while AllowOverridePrices is set to true.
What is now the best practice to override Order.Price.Price ? sql queries ?
This property is readonly.
// Assume o is your Order object
o.AllowOverridePrices = true;
o.Price.PriceWithVAT = o.Price.PriceWithoutVAT;
o.VAT = 0.0;
o.Save();
Now your o.Price.Price will return the correct price without VAT.
- Jeppe
Just changing the Order object values in the OrderIsPassedToCheckoutHandler is not enough. The Order object is only modified until the next Order is called or recalculated. I needed to set this code into my OrderTemplateExtender as well.
Now it works.
Thanks for inputs. I would like it to be more simple to manage such a simple requirement.
You must be logged in to post in the forum