Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 09-24-2018 04:55:27

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1568
Website

Merge Session and Stored Shopping Cart

Hi Nick

Sorry, another quick query.

So, a logged in user has a number of items in their cart. They log out and go away. Come back a few days later and their basket is empty as they are not logged in. They add an item to their cart and then remember they already have items in their cart from the other day so they log in to retrieve it. However, as they added an item during a KS session, their stored cart is deleted.

I assume this is the correct behaviour and not necessarily wrong.

Some of my items are more complicated than just clicking the add to cart button so I wanted a way to give the user an option to merge the session(KS) cart with any stored(KU) based cart.

My mod goes something like this:

Add checkbox form field in core-private\core\CORE_FrontEnd\ext\accounts.php with logic so it is only displayed if session cart is not empty(not necessary if session cart is empty) and if user is on AccountLogin page(don't want it displayed on CheckoutIntro page as I assume user has completed basket if they have got to this stage)

Modify user_login() in CORE_Session so that the cgi value of above checkbox can be passed to the user_mergecarts() function.

Modify user_mergecarts() in CORE_Session so that $mergeto cartid's are also saved in addition to $mergefrom cartid's if user want's the carts merged.

If a session user adds item to cart and goes to login page, the checkbox is preselected with description "Yes, please merge my current cart with any stored cart......". If they don't untick, the session and any stored carts are merged. This is exactly as Amazon cart works.

Everything works perfectly and I have tested extensively.

I always worry when messing with sessions and the shopping cart, so can you think of any problems this may encounter??


- Euorpacart 8

Offline

 

#2 09-24-2018 07:37:56

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19122
Website

Re: Merge Session and Stored Shopping Cart

What you describe as default behavior is accurate, and functioning as desired.  Your mod, if implemented properly in CORE_Session would do what you want.  The only gotcha is that you have to ensure the cartid is changed properly on whichever ecom_cart rows get move from an old cart to the new one.


Nick Hendler

Offline

 

#3 09-24-2018 07:41:13

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1568
Website

Re: Merge Session and Stored Shopping Cart

cartid is transferred and updated correctly.

Did get a little stuck until I realised I also needed to update the $cartdata['sortnum'] as you can't have two number 1's(which you would have if merged two separate carts)

old cartid's are still deleted.


- Euorpacart 8

Offline

 

#4 09-24-2018 07:55:30

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19122
Website

Re: Merge Session and Stored Shopping Cart

Good catch on the sortnum.  Now that you mention that, I'd also check that all randid fields are different, but as they're randomly generated, they should be.


Nick Hendler

Offline

 

#5 09-24-2018 07:59:53

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1568
Website

Re: Merge Session and Stored Shopping Cart

randid's are re generated ever time in the user_mergecarts()

I am testing with a completely empty ECOM_Cart table, so it makes it much easier to check everything is reloaded and deleted correctly.


- Euorpacart 8

Offline

 

Board footer