Developer forum

Forum » Integration » Live integration - shipping fee on cart/order

Live integration - shipping fee on cart/order

Keld Lauge Gøtterup
Reply

Ive been using the liveintegration source code and started modifying it to our needs, but ive run into a problem.

We want the navision system to make the calculation on shipment and just send us the result.

the xml received contains a column named OrderShippingFee in the Order and has a value set.

in the ProcessResponse function ive added the following:
order.ShippingFee.PriceWithVAT = Base.DoubleFromString(orderNode.SelectSingleNode("column [@columnName='OrderShippingFee']").InnerText);

but this doesn't overwrites the value it gets from DW, how can it to listen to the navision xml instead?


Replies

 
Dmitriy Benyuk
Reply

Hi Keld,

The problem may be in saving order. It is saved only when the create order option is set tot true(this occurs when the user confirms the order).
Is your order saved(call of order.Save() method) after setting the OrderShippingFee in ProcessResponse function?
 

 
Keld Lauge Gøtterup
Reply

Hi Dmitriy
 

hmm... i dont think i quite understand that.
Does that mean that shipping wont be correct until after the customer accepted the order?
I would think that is a bit late in the process.


but yeah the order is saved here:


                if (createOrder && bool.Parse(orderNode.SelectSingleNode("column [@columnName='OrderCreated']").InnerText))
                {                     
                    string orderStateID = Helpers.GetConfigValue(Constants.OrderSettings.Path, Constants.OrderSettings.OrderStateAfterExport);
                    if (!string.IsNullOrEmpty(orderStateID))
                    {
                        order.StateID = orderStateID; 
                    }
                    order.Save();
                }

 
Dmitriy Benyuk
Reply

Hi Keld,

I've debug the code for setting shipping fee: until the order is a cart(not completed) the Shipping Fee is a calculated property(and it is calculated by ShippingMethodID) so it is not possible to set it directly.

It is needed to set the ShippingMethodID for the order(or if it is not set the default shipping will be used) and create a custom shipping provider which can handle the shipping fee: http://developer.dynamicweb-cms.com/documentation/for-developers/ecommerce/extensibility/providers/fee-providers.aspx

 
Mikkel Toustrup Olsen
Reply

Hi Dimitriy,

I am currently working on the same "issue". I get the shipping fee from NAV as it is, but just as Keld i am not able to set the ShippingFee price as:

order.ShippingFee.PriceWithVAT = Base.DoubleFromString(orderNode.SelectSingleNode("column [@columnName='OrderShippingFee']").InnerText); 

It keeps it's default value as you mention.

I have created a custom FeeProvider and overridden the FindFee method. However, how do I parse the value from the response:  Base.DoubleFromString(orderNode.SelectSingleNode("column [@columnName='OrderShippingFee']").InnerText);  to the method? - It only takes 1 parameter, the Order - and as I cannot set the ShippingFee.PriceWithVat property im pretty stuck.

I was thinking of saving the shipping fee as a session and set it in the provider afterwards, if possible?

Am I missing something?

I dont quite understand the part with the "ShippingMethodID id for the order" , is there something I need to do? :-)

Thanks,

BR Mikkel

 

 
Dmitriy Benyuk
Reply

Hi Mikkel,
yes that should be possible: set some session variable with shipping fee got from Nav and inside CalculateShippingFee you can return the priceraw with shipping.
ShppingMethodID is used for calling the appropriate shipping provider for its calcualtion, so if it is not set, the default shipping provider is used.
Maybe as a workaround you can create a separate order line and call it like Shipping and set the Shipping price to it.
Regards, Dmitrij

 
Mikkel Toustrup Olsen
Reply

Hi Dmitriy, 

What i've done, which seems to be working:

I save the returned shipping fee from NAV into a session variable "ShippingFee". 

I then have a FeeProvider which overrides the FindFee() method which sets the order.ShippingFee.Price with the value from the session variable (if the session variable isn't null obviously) - Though I am not manipulating with ShippingMethodID or calling CalculateShippingFee() - am I missing something or doing something "wrong" in terms of this? :-)

FYI it's my first FeeProvider to date - however, as I wrote in the beginning - it seems to be working :-)

BR Mikkel

 

 

 

 

You must be logged in to post in the forum