Developer forum

Forum » Ecommerce - Standard features » Duplicate carts in CartsBeforeUserLogin

Duplicate carts in CartsBeforeUserLogin

Mikkel Ulstrup
Reply

Hi,

 

We are experiencing a problem when logging in with the following setting (all true):

  • Recalculate a user's cart when the user logs in
  • Keep anonymous cart when user logs in
  • Merge the anonymous cart content with the cart saved on the user when logging in

 

We have multiple OrderContexts, and when logging in, it duplicates the content from the anonymous cart.

In the BeforeLoginSubscriber in Ecoomerce.Common, you add carts to Dynamicweb.Context.Current.Items.Item("Dynamicweb:Ecommerce.CartsBeforeUserLogin").

First you add a cart without a context, then you add a cart for each existing context. - My suspicion is that the first one (the one without context) defaults back to a cart that actually has a context (maybe from the session), adding that exact cart twice.

 

My testing shows that the duplicates in Dynamicweb.Context.Current.Items.Item("Dynamicweb:Ecommerce.CartsBeforeUserLogin") have the same OrderContext (the orders are identical), which is weird that it is possible at all, and from the code, it seems to be the only explanation.

 

Later in the AfterLoginSubscriber, you loop through Dynamicweb.Context.Current.Items.Item("Dynamicweb:Ecommerce.CartsBeforeUserLogin") and add the orderlines from each order to the current order.

 

Maybe you could check if the same order allready exists in Dynamicweb.Context.Current.Items.Item("Dynamicweb:Ecommerce.CartsBeforeUserLogin") before adding it?

 

Kind regards

Mikkel Ulstrup


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi Mikkel,

I've tested all the three features on test environment based on last DW9.3.10 recently released and have correct results for regular/context cart in line with the manual explanation.

Perhaps, the issues are related to your specific solution. Please, submit new case in DW technical support service to have inivestigation.

BR, Oleg QA 

 

 

You must be logged in to post in the forum