Is there any way to add product directly to cart from a external link.
Example : Suppose I have my Odoo e-commerce website running on http://www.myodoo.com & I having a product which i am promoting from another website, now i want to set a link in such a way so when user click the link it will come to my Odoo e-commerce cart page with auto selection of that product and qty and other parameter, http://www.myodoo.com/shop/cart
So in this way no need to select the product and entry qty manually by end user , direct link maybe like http://www.myodoo.com/shop/cart?prouct='xyz'&qty=1.
Any help or suggestions are welcome....
Just write your own route.
@http.route('/shop/add-to-cart', type='http', auth="public", website=True)
cr,uid,context,registry = request.cr,request.uid,request.context,request.registry
#Check user input
product_id = int(pId)
product_id = None
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
#Redirect to cart anyway
I couldn't try this code, but it should work.
If you need help with writing modules. You can find useful information here
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 2/29/16, 10:43 PM|
|Seen: 510 times|
|Last updated: 8/3/16, 3:44 AM|