Developer forum

Forum » Ecommerce - Standard features » Multiple on the fly carts for users

Multiple on the fly carts for users

Peter Leleulya
Reply

I've been given a new assignment with functionality of which I'm not sure is possible out-of-the-box with Dynamicweb 9.
I've discussed this functionality with Morten Snedker and Jonas Karup Dam while I was in Denmark last week.
One of them told me it wasn't a problem, the other doubted if this could ever work (and if so expects a good chance on performance issues).
I hope someone can give me a conclusive answer and perhaps pointers on how to approach this (they pointed at Nicolai wink ).

Case:

We have a webshop.

We have customers which are dealers of products in our shop.
These dealers have customers of itself who do not exist in our shop.

The behavior we want to offer these dealers is an online equivalent of walking through a warehouse carrying multiple shoppingbaskets and being able to add shopping baskets on the fly.
So when you reach a product you can add this to one or more shopping baskets.

So, in the application you will have a shopping cart section in your screen with the option to add more shopping carts and give them a label to be able to recognice them.
This will becom a list of shopping carts in your screen (see image for functional display, ignore stock labels).

Products can be added to the available shopping carts.

Each shoppingcart can at any moment be checked out by itself, not effecting the others.

When getting back to the application the open shopping carts still remain until removed or checked out.


What I know:

I know of order contexts.

I'm aware you can configure ordercontexts via the CMS for example to enable a daily-, a weekly-, and a monthly shopping cart.
This doesn't seem usefull for my case.

I'm aware ordercontexts can be created in code. I've used them when we generated websites with corresponding shops, but then we had one ordercontext per website-shop combination for all users of that website.
This doesn't seem usefull for my case.

I'm not aware of multiple ordercontexts per user per website, which I'm looking for.
Maybe there is a distinction between ordercontexts and ordercontextcarts which I don't fully understand, but can't find good documentation or samples about either.

 

 

I hope someone knows how to approach this ...

Schermafbeelding_040417_031512_PM.jpg

Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Peter,

We've played with OrderContexts a while and we also managed to implement multiple Contexts for the same user.

One of the questions I have is how persistent should the Cart names be. Should they remain available to the user for the next shopping session?

Adding a product in a specific context is not complicated. It's just a parameter in the Add to cart call. You can predefine a number of contexts and assign them as the user requests new carts. A maximum number of contexts would be advisable because it will definitely affect the performance if you have a lot of contexts. At least in the older versions it did affect the performance. But if you define 10 or 20 contexts, you should be fine.

If they should not be persistent, you can store the friendly name of the ordercontext in Session (or any other method you prefer) and then use that information to select the cart you want to add to or display. The carts will be available only inside a loop of contexts. I believe there is a sample code somewhere on this website.

I am no programmer so I cannot give you advice on the code to use :)

Adrian

 
Peter Leleulya
Reply

Thanks for your response Adrian.
I'm quit sure no dealer will have more than 20 carts simultaniously, that seems unworkable to me.
What I do wonder if I have to dispose the ordercontexts I create or wil that ber done automagically ...
I can imagine with such a functionality a clutter up of ordercontexts will become an issue at some point ...

 
Jonas Krarup Dam
Reply

Hi Peter,

I believe the idea is that you create the OrderContexts once, and then "assign" carts to a specific context. 

Each user in Dynamicweb can have one cart per OrderContext, so  you will have 

OrderContext1

OrderContext2

OrderContext3

...

 

When a user needs to create a new cart, you pick the first context that does not currently contain an order.

OrderContext1-> Customer5Cart

OrderContext2->Customer23Cart

OrderContext3 -> no cart

...

You'll have to do some housekeeping to keep track of which customer is in which OrderContext, possibly using a custom orderfield or something.

 

This way, a context will be empty and available as soon as you either empty a cart or check it out.

 

You will not be creating/removing OrderContexts on the fly - you will be reusing the same 20 ordercontexts again and again.

Hope this makes sense.

 

/Jonas

 

You must be logged in to post in the forum