Developer forum

Forum » Ecommerce - Standard features » Selective cart isolation

Selective cart isolation

Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hello,

For the cart isolation feature ("Full cart isolation per browser, even for the same user"), is it possible to use that selectively? We are starting a Punchout project where we would like to use this isolation, but we only want to use it for Punchout sessions and not for all sessions.

Since we log in the user programmatically, can we call this through an API call when we log the user in?

Thanks,

Scott


Replies

 
Jan Sangill
Reply

Hi,

I am bumping this in hopes someone have a great idea here.

I need it for the same purposes as Scott. 

I dont want to enable this sitewide, but only for certain users - for punchout.

I hope someone have some good ideas.

//jan

 
Nicolai Pedersen
Reply

I was playing around with something like this. But it will not work unless you hijack the entire DynamicwebHttpHandler...

So what I think is needed is a new property on the user "IsolateCart" or similar, and if that is et on the user, the cart context can be isolated.

private static object SyncLock = new object();

            //some handler
            lock (SyncLock)
            {
                SystemConfiguration.Instance.SetValue("/Globalsettings/Ecom/Cart/FullCartIsolation", true);
                //Handle the punchout session
                var pv = new Dynamicweb.Frontend.PageView() { Redirect = false };
                pv.ID = 12;
                pv.Load();
                var output = pv.Output();
                SystemConfiguration.Instance.SetValue("/Globalsettings/Ecom/Cart/FullCartIsolation", false);
                Response.Write(output);
                
            }

 
Jan Sangill
Reply

Hi Nicolai, TY for the response. Will test this out and see how this works.

Appreciated!

 
Jan Sangill
Reply

Hi Nicolai, Just a follow up question.

Would it also be possible to do something like this specifically for punchout users? Instead of using this flag FullCartIsolation. I tried playing around with whats below in OnExtranetLogin subscriber. The cart is created - but when I then add something to a cart it creates a new cart. Does it not make sense to follow this path and is it possible? Or would you recommend the suggestion you had above? My example code is below for creating the cart in the subscriber.

Any thoughts appreciated.

code:

string contextId = System.Web.HttpContext.Current.Session.SessionID;
Context.CartContext = new OrderContext() { Id = contextId, Name = contextId, Shops = new List<string>() };
Context.CartContext.Save();

var orderService = new OrderService();
var cart = new Order(Context.Currency, Context.Country, Context.Language) { IsCart = true, LanguageId = Context.LanguageID, ShopId = "SHOP6", OrderContextId = contextId, VisitorSessionId = contextId};
orderService.Save(cart);

Context.SetCart(cart);
Context.SetPersistentCartContext(contextId);

 

You must be logged in to post in the forum