Jump to content

Create cart and product for another user


Recommended Posts

Hi everyone!

I am really struggling with a problem and would like to know if anyone has a solution to offer. I want to, as an admin of my site, create a cart for another user of my shop and add a product to my cart.

This, to me, seems logical but it's not working (I get the ids before so that's not the problem):

                        $cart = new Cart();

                        $cart->id_customer = $id_customer;

                        $cart->id_currency = $currency->id;

                        $cart->id_lang = $id_lang;

                        $cart->id_shop = $id_shop;

                        $cart->add();

 

                        $productId = XXX (a valid product id);

                        $quantity = 1;

 

                        $cart->updateQty($quantity, $productId );

                        $cart->update();

 

Any help would be appreciated!

 

Edited by AminaM (see edit history)
Link to comment
Share on other sites

Hello, how are you? Have you checked that the AJAX calls are working correctly and that you're receiving a response from the controller even if it's an error? It might seem like a trivial question, but making small breakpoints in the controller's responses will help you identify the error. Some EXIT or DIE statements with corresponding control notes will help you pinpoint the issue. Best regards.

Link to comment
Share on other sites

Hello, I'm doing great, hope you are too. My problem is that I am told that there is an error 500, but no error log is provided to help me fix the issue. so it kind of feels like I'm wandering in the dark...

I think I will have workaround this problem because it is too time consuming.

Thanks a lot for your help!

Link to comment
Share on other sites

The 500 error is indicative of a server error. If you have it in your browser at that moment and you know how it occurs, simply inspect the browser and go to the network tab. If you don't have debug mode enabled, it may not show errors except for the mentioned 500 error. But if you go into your function now and step through it, interrupting it with die or exit statements, you will receive the exact moment of the situation where your Ajax call is not working. I hope this helps. Sorry for the long speech, have a great day.

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...