AminaM Posted September 19, 2023 Share Posted September 19, 2023 (edited) 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 September 19, 2023 by AminaM (see edit history) Link to comment Share on other sites More sharing options...
Yelish Posted September 20, 2023 Share Posted September 20, 2023 I don't quite understand in what environment you're doing this, on the front end of your store? In a front-end controller of a module? This is important. Regards. Link to comment Share on other sites More sharing options...
AminaM Posted September 20, 2023 Author Share Posted September 20, 2023 Hi Yelish, Thank you for your answer, I am working in the front-end of my store, in an ajax file, so I guess the context is different. Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted September 20, 2023 Share Posted September 20, 2023 I'm not sure if it's what you are searching but my module do the job i guess : https://addons.prestashop.com/en/remarketing-shopping-cart-abandonment/86387-op-art-save-cart-save-and-share-cart-by-link-or-email.html Link to comment Share on other sites More sharing options...
Yelish Posted September 21, 2023 Share Posted September 21, 2023 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 More sharing options...
AminaM Posted September 21, 2023 Author Share Posted September 21, 2023 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 More sharing options...
Yelish Posted September 21, 2023 Share Posted September 21, 2023 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now