This question has been flagged
2 Replies
2050 Views

Hi,

This is my custom code ,version=10


@http.route('/wishlist/add-to-cart', type='http', auth="public", website=True)

    def add_to_cart(self,product_id,qty=1):

        cr, uid, context, registry = request.cr, request.uid, request.context, request.registry

    # Check user input

        try:

            product_id = int(product_id)

        except:

            product_id = None


        if product_id:

            product_id = registry["product.product"].browse(cr, uid, [product_id])


        # Is the product ok

            if product_id and product_id.sale_ok and product_id.website_published:

            # Get the cart-sale-order

                so = request.website.sale_get_order(force_create=1)

            # Update the cart

                so._cart_update(cr, uid, product_id=product_id.id, add_qty=1)


            # Redirect to cart anyway

        return request.redirect("/shop/cart")

Avatar
Discard
Best Answer

Hi

Could you please check the url generated by your custom button. It seems like the "product_id" does not pass to your add-to-cart method.

Best regards,

Tim

Avatar
Discard
Best Answer

no fix ?

Avatar
Discard