Developer forum

Forum » Integration » Integration Framework and multiple currencies

Integration Framework and multiple currencies

Anders Ebdrup
Reply

Hi Dw,

 

I have a big problem with the Integration Framework (Ax integration), which loads the cart from the ERP-system on "Dynamicweb.Notifications.eCommerce.Cart.Loaded" and this event happens in the first line marked with bold, but the Currency in the Context is first set in the second line marked with bold.

 

This result in this error: Attempt to aritmatic with two prices of different currency

 

As I see it, the right context should be loaded before the cart...

 

        Friend Shared Sub LoadedPage(ByVal page As PageView)

            Dynamicweb.eCommerce.Frontend.CatalogPublishing.CatchCatalogPublishing.CatchCatalog(page.ID, page)
            Dynamicweb.eCommerce.Frontend.Cart.CartCatch.CatchCart(page.ID, page)

            If Not Common.Functions.IsPageviewLocked(page) Then
                If Base.ChkString(page.Area.Value("AreaEcomLanguageID")) <> String.Empty Or Base.ChkString(page.Area.Value("AreaEcomCurrencyID")) <> String.Empty Then
                    If Not Dynamicweb.eCommerce.Common.Context.LanguageSetByCustomer Then
                        Dynamicweb.eCommerce.Common.Context.Language = Dynamicweb.eCommerce.Common.Application.Language(Base.ChkString(page.Area.Value("AreaEcomLanguageID")))
                    End If

                    If Not Dynamicweb.eCommerce.Common.Context.CurrencySetByCustomer Then
                        Dynamicweb.eCommerce.Common.Context.Currency = Dynamicweb.eCommerce.Common.Application.Currency(Base.ChkString(page.Area.Value("AreaEcomCurrencyID")))
                    End If

                    If Not Dynamicweb.eCommerce.Common.Context.CountrySetByCustomer AndAlso Not String.IsNullOrEmpty(Base.ChkString(page.Area.Value("AreaEcomCountryCode"))) Then
                        Dynamicweb.eCommerce.Common.Context.Country = Dynamicweb.eCommerce.Common.Application.Country(Base.ChkString(page.Area.Value("AreaEcomCountryCode")))
                    End If
                End If

                'Added for displaying and "security" reasons
                Dim changeCulture As Boolean = True
                Dim cart As Orders.Order = Common.Context.Cart()
                If cart IsNot Nothing Then
                    If cart.StepNum = 6 Or cart.Complete Then
                        changeCulture = False
                    End If
                End If

                If changeCulture Then
                    If Base.Request("LanguageID") <> String.Empty Then
                        Dynamicweb.eCommerce.Common.Context.LanguageSetByCustomer = True
                        Dynamicweb.eCommerce.Common.Context.Language = Dynamicweb.eCommerce.Common.Application.Language(Base.Request("LanguageID"))
                    End If

                    If Base.Request("CurrencyCode") <> String.Empty Then
                        Dynamicweb.eCommerce.Common.Context.CurrencySetByCustomer = True
                        Dynamicweb.eCommerce.Common.Context.Currency = Dynamicweb.eCommerce.Common.Application.Currency(Base.Request("CurrencyCode"))

                        If Common.Context.Cart IsNot Nothing AndAlso Common.Context.Cart.OrderLines IsNot Nothing Then
                            Common.Context.Cart.OrderLines.RemoveDiscounts()
                            Common.Context.Cart.OrderLines.RemoveTaxes()
                            Common.Context.CartDiscountsAndTaxesAreHandled = False
                        End If
                    End If

                    If Base.Request("CountryCode") <> String.Empty Then
                        Dynamicweb.eCommerce.Common.Context.CountrySetByCustomer = True
                        Dynamicweb.eCommerce.Common.Context.Country = Dynamicweb.eCommerce.Common.Application.Country(Base.Request("CountryCode"))
                    End If
                End If
            End If
        End Sub

Best regards, Anders


Replies

 
Jonas Krarup Dam
Reply
This post has been marked as an answer

Hi Anders,

I do see the problem, but unfortunately, we are not able to simply move the assignment to Context.Currency, as that is very likely to cause problems with some of the default implementations for calculating prices, carts, etc.

I seem to recall seeing this problem before, where the solution was to simply do the assignement to Context.Currency in the custom code, in the notification subscriber. Assuming you are using the AX integration as a replacement for the price calculations done in Dynamicweb, this should work as needed, without running into the problems we would face, if we tried to move it in our code.

If it doesn't work, please let me know, and I'll try to investigate further.

Regards, Jonas

Votes for this answer: 1
 
Anders Ebdrup
Reply

Hi Jonas,

 

Yes, that have solved the problem for now, but the same problem seems to be in the default code for the Integration Framework, so I am hoping for a generic solution for this :-)

 

Best regards, Anders

 
Morten Snedker
Reply

Hi Anders,

 

There will be a lasting solution for this coming up. However, we have yet to decide if this is to be solved in the "stomach" of DW, or in Data Integration explicitly.

But it is on our to-do! :-)

 

Regards /Snedker

 
Anders Ebdrup
Reply

Hi Morten,

 

Thank you very much! That was exactly the answer that I was hoping for :-)

 

Best regards, Anders

 

You must be logged in to post in the forum