Jump to content

Programmatically "selecting" New Cart For Current User


Guest

Recommended Posts

Hey there, merry Christmas to all.

 

I have a Cart object which I duplicate to generate the same Cart (its contents) with a different id.

Then I delete the previous Cart object.

 

What I am trying to do now is selecting the new Cart object, so that when the user is redirected, they can see the newly created Cart.

 

I've looked around in core files' code to see how this could be done (asigning the cart id. to the Context object, for example), but I've had no luck.

 

I've also seen that the new Cart has been properly created (it is displayed in the back-end), and I've also noticed that if the user logs out and back in, the new cart is properly loaded. 

 

Could you share a code snippet so I can properly do this?

 

 

My code right now is something like this:

$new_cart = $cart->duplicate();
$cart->delete();


// I'm guessing I have to do something now with the $context object to load the cart for the current user

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...