London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Share cart across devices/browsers

Vote:
0

Hi there,

I have a case where I would like to share an "anonymous" cart across devices. Here it is possible for me to send "CustomerId" in a QueryString to the other device.

I use this code to share the cart between devices:

public ICart CloneAndLoadCart(Guid customerId)
        {
            var existingCart = _orderRepository.LoadCart<ICart>(customerId, DefaultCartName, _currentMarket);

            if (existingCart == null)
                return null;

            var clonedCart = (ICart)((Mediachase.Commerce.Orders.Internal.IDeepCloneable)existingCart).DeepClone();
            clonedCart.CustomerId = CustomerContext.Current.CurrentContactId;
            SaveCart(clonedCart);
            return clonedCart;
}

Can it be done in a better / nicer way?

It is said here, that "IDeepCloneable Interface" "is not intended to be used directly from your code".

Br

Lasse

#208707
Edited, Oct 30, 2019 13:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.