Developer forum

Forum » Ecommerce - Standard features » Shipping Fee - Value changed

Shipping Fee - Value changed

Rui Silva
Reply

Hi,

In the project I working now I have one site using different currency that the default solution currency. The default currency of the solution is USD and one of the sites in the solution in the ecommerce settings uses EUR.

When I add my custom fee to the order in the site with different currency it seems that DW is making a conversion to the default solution currency and not using the currency defined in the ecommerce for the site. This makes the order calculation to result to an incorrect total.

I've checked that the order object has the correct currency value and that the PriceRaw object I'm creating in the fee provider also returns the same currency of the order that matches the currency defined for the site in the ecommerce settings.

 

Best,

Rui Silva


Replies

 
Nicolai Høeg Pedersen
Reply

Can you post your code?

 
Rui Silva
Reply

Hi Nicolai,

Here is the code:

    public class LiveShippingFeeProvider : FeeProvider
    {
        public override PriceRaw FindFee(Order order)
        {
            // order custom field with shipping fee
            OrderFieldValue orderField = order.OrderFieldValues.FirstOrDefault(ofv => ofv.OrderField.SystemName == "ERPShippingFee");

            PriceRaw returnFee = null;
            var o = HttpContext.Current.Session["ShippingFee" + order.ID];
            if (o != null)
            {
                double feeValue = Convert.ToDouble(o);
                returnFee = new PriceRaw(feeValue, order.Currency);

                if (orderField != null)
                    orderField.Value = feeValue;
            }
            else if (orderField != null && orderField.Value != null && orderField.Value != DBNull.Value)
                returnFee = new PriceRaw((double)orderField.Value, order.Currency);

            return returnFee;
        }
    }

As you may notice I read the value from a custom field or from a session variable. The custom field always has the correct value, but in the order the value seems to be converted to the Dynamicweb.eCommerce.Common.Application.DefaultCurrency that doesn't match to the site ecommerce currency setting.

I only notice this when using a site with a different currency that is in setting Dynamicweb.eCommerce.Common.Application.DefaultCurrency.

Best,

Rui Silva

 
Nicolai Høeg Pedersen
Reply

If you debug this, what is the currency of order.Currency when this is executed?

 
Rui Silva
Reply

The order.Currency has the correct value "EUR" and the Dynamicweb.eCommerce.Common.Application.DefaultCurrency is "USD" and finaly the Dynamicweb.Frontend.PageView.Current().Area.get_Value("AreaEcomCurrencyID") is "EUR" that is correct.

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Rui

I can see that it is a bug - the shipping calculator does not look at the currency set on the Rawprice but uses default. TFS#25093, ready with next hotfix.

Votes for this answer: 1

 

You must be logged in to post in the forum