Developer forum

Forum » Integration » Liveintegration - shipping fee

Liveintegration - shipping fee

Kenneth Radoor
Reply

Using (almost)standard live-integration as supplied from DW, we have som strange behavoir, when getting data for an order from NAV.

We are getting user specific prices for at loggedin customer, and setting those prices on the order. That is all fine.

The problem is the fee for shipping is not getting set.

The orders totalprice is not updated to reflect the shipping option selected.

If we try to call "order.ForcePriceRecalculation()" then the shippingfee is set, if we make a second update call to the cart.

Looking at it in the debugger, we can se that on the first call, the shippingmethod is not set to reflect the "changed" shipping. Doing an update to the cart, the fee is correct.

I am attaching the c# file for reference

/Kenneth

 

 


Replies

 
Dmitriy Benyuk
Reply

Hi Kenneth,
could you re-attach your file, I can't download it.
Thx
Regards, Dmitrij

 
Kenneth Radoor
Reply

Hi Dmitriy

Here is a link til a gist:

https://gist.github.com/imade-dk/ce7d3a5d450d3fbc4d38

and the code is attached as a zip

//Kenneth

 
Dmitriy Benyuk
Reply

Hi Kenneth,

I was using the standard live integration code and found that I need just one line of the code:

order.ForcePriceRecalculation();
to be called in the end of the OrderHandler::ProcessResponse() method for recalculating the order price to include the shipping fee.

One note about the ForcePriceRecalculation method: it adds all orderlines prices and then adds a shipping fee.
So maybe this amount is different from the one that is set in:
order.Price.PriceWithVAT = orderPriceWithVAT;

I as using Dynamicweb 8.7.2.3. Could you hint what version are you on? And what shipping provider with what options do you use?
Regards, Dmitrij

 
Kenneth Radoor
Reply

Hi

DW version: 8.6.1.25

Shippingprovider: GLS (parcel_Type: A, Shipment_type: A) or none

Payment:  ePay or none

In this case it does not make any difference if I call ForcePriceRecalculation or not, the total do not get updated to the correct price until a second update of the page.

We do not get the shipping fee form NAV, only the price of the total order + the individual orderlines.

I have tried to add the shepping fee to the pricewithVat, like:

var orderPriceWithVAT = Base.DoubleFromString(orderNode.SelectSingleNode("column [@columnName='OrderPriceWithVAT']").InnerText.Trim());
order.Price.PriceWithVAT = orderPriceWithVAT + order.ShippingFee.Price;
order.PriceBeforeFees.PriceWithVAT = orderPriceWithVAT;

No change, needs 2 updates of the page before the order price gets reflected to the output.

One downside of calling ForcePriceRecalculation is the when ever its done, no matter where, the order.Price.VAT gets zeroed out :(

it doesnt matter if i call @Ecom:Order.OrderLines.Total.PriceVAT or @Ecom:Order.Price.VAT, both of them is zero, and remains zero all the time.

/Kenneth

 
Dmitriy Benyuk
Reply

Hi Kenneth,
I still can't reproduce it on DW 8.6.1. (I was using latest 8.6.1.28 and PostDanmark delivery provider). It was working for me without code changes and with your suggestion:
var orderPriceWithVAT = Base.DoubleFromString(orderNode.SelectSingleNode("column [@columnName='OrderPriceWithVAT']").InnerText.Trim());
order.Price.PriceWithVAT = orderPriceWithVAT + order.ShippingFee.Price;
order.PriceBeforeFees.PriceWithVAT = orderPriceWithVAT;

var orderPriceWithVAT = Base.DoubleFromString(orderNode.SelectSingleNode("column [@columnName='OrderPriceWithVAT']").InnerText.Trim());
order.Price.PriceWithVAT = orderPriceWithVAT + order.ShippingFee.Price;
order.PriceBeforeFees.PriceWithVAT = orderPriceWithVAT; - See more at: http://developer.dynamicweb.com/forum/integration/liveintegration-shipping-fee.aspx#sthash.l7VFRCb0.dpuf

Could you try to add the tags for output the order shipping information "Ecom:Order.ShippingFee", "Ecom:Order:ShippingMethod" to your cart template?
Could you check if it works with another shipping provider and check if the language you enter for the shipping provider mathes the current web site language?
Regards, Dmitrij
 

 
Kenneth Radoor
Reply

hi

I already have those 2 tags in the template and they are ok, i get the right method and price. and everything should be set up as it should.

I have just updated the solution to 8.7.2.4, same result

The problem is the total price of the order that is not updated until i have made a 2. submit.

So its the tag Ecom:Order.OrderLines.Total.Price, that is one submit behind

I have attaced the template i use.

/Kenneth

 
Dmitriy Benyuk
Reply

Hi Kenneth,
could you check the suggestions from Jonas and see if they could help you?
Regards, Dmitrij

 
Jonas Krarup Dam
Reply

Hi Kenneth,

As I understand it, you are trying to do part of the calculation in a remote system (prices, stock check, etc), and some part of the calculation in Dynamicweb (shipping fee calculation).

As the price calculation is implemented in Dynamicweb, I don't belive that it is possible to seperate the two. My advice is to keep all order calculations in one place - either in Dynamicweb, or in  the external system. You can still use the live integration to do stock-checks, but mixing up order price calculations is going to be messy.

Regards, Jonas

 
Kenneth Radoor
Reply

Hi Jonas.

The whole solution is pretty much standart out of the box. I have only added some extra fields, mostly for custermer info.

In the "CalculateOrder" there is added fields for "OrderPaymentMethodFee" and "OrderShippingMethodFee", because of the differens in the way NAV and DW handles fees. in NAV it is as far as i understand just orderlines, and in DW they are entities in them self.

The responce we get back from NAV is out of the box, and the way it is handled in the integration-project (orderHandler::ProcessResponse) is out of the box.

So i cant see that we are doing any calculations other than what is out of the box.

If it is this line you stunpled opon (order.Price.PriceWithVAT = orderPriceWithVAT + order.ShippingFee.Price; , then it was just a test

What i do not understand is that if i change the shippingmethod and submit that change, then the total of the price do not get set to the right price.

When i do a second submit with the same settings (CartV2.CurrentStepButtonName), then everything is fine.

Regards, Kenneth

 

 

 
Jonas Krarup Dam
Reply

Hi Kenneth,

The "out of the box" example code hasn't been tested with shipping fees, and as far as I know, shipping fees aren't implemented in the NAV code unit.

In your previous post, you wrote "We do not get the shipping fee form NAV, only the price of the total order + the individual orderlines". This is what I am refering to, when I say that you have some of the calculations in DW and some in NAV.
The Integration isn't ment for split calculations like that, and the "out of the box" implementation does not support it. All calculations should be done in NAV.

As you say, in NAV, shipping is treated as seperate orderlines. If these orderlines are returned in the response XML, and the total that is returned in the response XML includes the Shipping fee, then this information will be available in your orderline loop in the frontend - you are not supposed to do any kind of calculations on the order in the liveIntegration project.

Since we haven't tested the example code with shipping fees, so it is possible that some adjustements are required in the NAV codeunit, in order to get the shippingfees transfered to DW correctly.

If I am misunderstanding your setup, please let me know!

Regards, Jonas

 
Kenneth Radoor
Reply

Hi.

In the order node i have added a node(OrderShippingMethodFee) the gives the fee to NAV.

NAV is returning the induvidual order lines + the totals in the order-node. NOT including the shippingfee in any of the prices.

This is what we send:

<CalculateOrder>
  <Orders>
    <Order>
      <column columnName="OrderCustomerAccessUserExternalId">E000935</column>
      <column columnName="CreateOrder">False</column>
      <column columnName="OrderID">CART59</column>
      <column columnName="OrderIntegrationOrderID"></column>
      <column columnName="OrderCurrencyCode">DKK</column>
      <column columnName="OrderDate">16-12-2015 18:14:19</column>
      <column columnName="OrderPaymentMethodName">Faktura</column>
      <column columnName="OrderShippingMethodName">GLS</column>
      <!--Columns with customer data left out-->
      <column columnName="OrderShopId">SHOP1</column>
      <column columnName="OrderPaymentMethodFee">0</column>
      <column columnName="OrderShippingMethodFee">80</column>
      <column columnName="OrderDeliveryCompany"></column>
      <column columnName="OrderCustomerNumber">451602</column>
      <Fields>
        <column columnName="OrderFromShopId"></column>
        <column columnName="EksterntBilagsnr"></column>
      </Fields>
    </Order>
  </Orders>
  <OrderLines>
    <OrderLine>
      <column columnName="OrderLineID">OL4466</column>
      <column columnName="OrderLineProductID">BI-NEXIAPM</column>
      <column columnName="OrderLineProductVariantID"></column>
      <column columnName="OrderLineQuantity">1</column>
    </OrderLine>
  </OrderLines>
</CalculateOrder>

 

And this is what we recieve:

 

  <table tableName="EcomOrderLines">
    <item table="EcomOrderLines">
      <column columnName="OrderLineProductNumber"><![CDATA[BI-NEXIAPM]]></column>
      <column columnName="OrderLineProductVariantID"><![CDATA[]]></column>
      <column columnName="OrderLineID"><![CDATA[10000]]></column>
      <column columnName="OrderLineQuantity"><![CDATA[1]]></column>
      <column columnName="OrderLineType"><![CDATA[0]]></column>
      <column columnName="OrderLinePriceWithoutVAT"><![CDATA[9,251.20]]></column>
      <column columnName="OrderLineUnitPriceWithoutVAT"><![CDATA[9,251.20]]></column>
      <column columnName="OrderLinePriceWithVAT"><![CDATA[11,564.00]]></column>
      <column columnName="OrderLineUnitPriceWithVAT"><![CDATA[11,564.00]]></column>
      <column columnName="OrderLinePriceVAT"><![CDATA[2,312.80]]></column>
      <column columnName="OrderLineUnitPriceVAT"><![CDATA[2,312.80]]></column>
      <column columnName="OrderLinePriceVATPercent"><![CDATA[25.00]]></column>
      <column columnName="OrderLineUnitPriceVATPercent"><![CDATA[25.00]]></column>
    </item>
  </table>
  <table tableName="EcomOrders">
    <item table="EcomOrders">
      <column columnName="OrderCreated"><![CDATA[FALSE]]></column>
      <column columnName="OrderID"><![CDATA[]]></column>
      <column columnName="OrderCurrencyCode"><![CDATA[]]></column>
      <column columnName="OrderDate"><![CDATA[]]></column>
      <column columnName="OrderPaymentMethodName"><![CDATA[]]></column>
      <column columnName="OrderShippingMethodName"><![CDATA[]]></column>
          <!--Columns with customer data left out-->
      <column columnName="OrderDeliveryPhone"><![CDATA[]]></column>
      <column columnName="OrderDeliveryZip"><![CDATA[]]></column>
      <column columnName="OrderPriceWithVAT"><![CDATA[11,564.00]]></column>
      <column columnName="OrderPriceWithoutVAT"><![CDATA[9,251.20]]></column>
      <column columnName="OrderPriceVAT"><![CDATA[2,312.80]]></column>
      <column columnName="OrderSalesDiscount"><![CDATA[0.00]]></column>
      <column columnName="OrderShippingFee"><![CDATA[]]></column>
    </item>
  </table>
</tables>

What really puzzles me is that the prices is correct in a second submit. If it was because of some calculation in NAV or DW, then the result should be wrong each time.

 

Regards, Kenneth

 

 
Jonas Krarup Dam
Reply

Hi Kenneth,

Ok, just checking that I am understanding you correctly: if you send the same XML twice (by reloading the cart, or going to the next step or something), then NAV returns a different result the second time?

If that is  the case, then the problem is definitely in NAV - NAV should always return the exact same prices (Assuming of course that noone has changed anything in NAV between requests). Also, if you have added the field "OrderShippingMethodFee", and is expecting that to be added to the order total on NAV, that needs to be handled by your NAV developer.

If that is not the case, then do not understand what is going wrong, or what you would like to happen?

 

 
Kenneth Radoor
Reply

hi

For the same order with the same products, NAV returns the exact same each time.

There is no handeling of the shippingfee in NAV until the order is marked as completed, as NAV uses orderlines for fees, and DW has it's way of dealing with fees.

So what we get is the total of the ordes products, with and without VAT + all the individual orderlines.

Senario;

Shop has a default delivery fee of 50,-

An order with one product prices 100,-,

enter basket, total price of order: 150,-

Change the shipping method to free delivery.

Update cart and total order price is still 150,-

After second update the total order price is then 100,-

 On all roundtrips to NAV the xml has been the exact same.

 

Regards Kenneth

 
Jonas Krarup Dam
Reply

Hi Kenneth,

I think this might be confusing me more than it should.
Can we talk on skype instead, to make sure I understand your problem?

you can send your skypeID to me: jkd@dynamicweb.dk, and I will contact you
 

Regards, Jonas

 

You must be logged in to post in the forum