从购物车中删除产品-网站Odoo 9 [英] Remove products from shopping cart - Website Odoo 9

查看:119
本文介绍了从购物车中删除产品-网站Odoo 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何创建模型(或扩展现有模型)以从Odoo9中的购物车中删除产品.

I want to know how can i create a model (or extend existing one) for deleting a products from the Shopping cart in Odoo9.

问题在图片中描述.我应该添加一个按钮,当我按下该按钮时,将完全删除该产品,与给出的数量无关.

The problem is described on the picture. I should add a a button and when i press it will delete the product completely doesn't matter which quantity is given.

先谢谢您

亲切的问候, 伊戈尔(Igor)

Kind regards, Igor

推荐答案

当产品的数量达到0时,该产品将从您的购物车中删除.因此,请尝试使用已存在的功能,而不要创建自己的JavaScript.

A product is removed from your cart when its quantity reaches 0. Therefore try to use that function that already exists rather than creating your own javascript.

您可以在website_sale/views/templates.xml上的id="cart"模板上插入按钮,单击该按钮时应调用js脚本.

You can insert your button on website_sale/views/templates.xml On the template with the id="cart" and when clicked it should call a js script.

请参见wesbsite_sale/static/src/js/website_sale.js,检查以

$(oe_website_sale).on("change", ".oe_cart input.js_quantity[data-product-id]", function () {

这段代码观察产品数量的变化,如果数量达到0,它将删除整行.

This piece of code observes for changes in the quantity of the products and if the quantity reaches 0 it removes the whole line.

因此您可以将要删除的行的数量更改为0,而现有的代码将删除该行.

这篇关于从购物车中删除产品-网站Odoo 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆