Developer forum

Forum » CMS - Standard features » Manage carts using API

Manage carts using API

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a project where I need to create and manage multiple carts and I have 2 questions:

1. Can we have multiple carts even for Anonimous?

2. Can I manage the carts (create, rename, select) using the API?

I am using DW 9.9.8

Thank you,


Adrian


Replies

 
Nicolai Pedersen
Reply

@1: Yes - use contexts.

@2: The cart is just an order object - so you can use the order instance and do your changes.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I was trying to avoid using contexts because it seems more complicated to set the current cart. Using Cart commands seemed a bit more straightforward.

CartContext was out first approach but it seems more complicated to switch the information about carts without changing a lot in the templates.

Our requirement is that we need to separate one of the product types in a separate order.

I can easily decide to add it to a separate OrderContext but I have some trouble displaying information in Minicart or Cart without separating the pages and templates.

I need to have the same order flow for all product types.

With CartCommands it seemed that I can simply set a Cart as "Active" using "setcart":
<a href='@baseurl&cartcmd=setcart&CartID=@cart.GetString("Ecom:Order.ID")'>Set Cart</a>

And this would change what I see in the minicart and order flow, which means I can already use the current templates and setup.

I don't know if I can do the same with OrderContext. If I can, this would be my first option indeed.

What do you think?

Thank you,
Adrian

 

 

 
Nicolai Pedersen
Reply

I think you should go with whatever works for you.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

That's what I am trying to do :)

The trouble is how I decide what works for me :)

It is clear that using CartCommands would not work since it is not supporting the Anonymous users.

Which leaves me the only option of OrderContext.

The question now is if I can change the current Context using the API (or a POST similar to the CartCommands).

Thank you,
Adrian

 

You must be logged in to post in the forum