Skip to Content
Menu
This question has been flagged

I am trying to add a product to the cart through an AJAX request. 
Just from the front-end in the website module. 
Is this even possible?

It is not taking in the 'product_id' parameter. 

I can't find any clear documentation on these functions.

Where can I find these resources?

~ Odoo 17.1

Avatar
Discard
Best Answer

Hi Max,

In this query, you did not provide information about the method you wrote, so I assumed you were referring to a method called cart_update_json() within the WebsiteSale class."

The error message you're encountering indicates that the method cart_update_json() in the WebsiteSale class is missing a required positional argument, which is product_id. This suggests that when calling the cart_update_json() method, you're not providing the required product_id argument.

Here's a general understanding of what might be happening and how you can resolve it:

  1. Check Method Signature: Make sure you're calling the cart_update_json() method with the correct number of arguments and in the correct order. If the method expects a product_id argument, ensure that you're passing it when calling the method.
  2. Inspect Code: Look into the definition of the cart_update_json() method in the WebsiteSale class to understand how it's implemented and what arguments it expects. Ensure that you're providing all the required arguments when calling the method.
  3. Debugging: If you're still unsure why the error is occurring, you can add print statements or use a debugger to inspect the values of variables and arguments leading up to the call of cart_update_json(). This can help identify any issues with variable values or argument passing.
  4. Check for Overrides: If you've overridden the cart_update_json() method in a custom module or template, ensure that your implementation still follows the correct signature and usage of the original method.


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
1
Apr 23
1937
3
May 19
5539
1
Dec 24
1504
0
Oct 22
659
0
Oct 22
379