从购物车中删除产品之前的确认消息

Confirmation message before removing a product from cart

我刚刚注意到,在 WooCommerce 中,如果客户从购物车中删除产品,删除之前没有警告消息或确认。

在从购物车中移除产品之前,有什么方法可以进行确认吗?

谢谢。

如果您查看 WC_Cart remove_cart_item() method source code here,您会在第 1015 行看到您只能使用 woocommerce_remove_cart_item 在删除项目之前触发的操作挂钩来自购物车。

由于删除项目是 ajax 在购物车页面中驱动的,因此执行您期望的操作当然是可能的,但确实有些复杂。

Remember that on cart page, you already got a notice when you remove a cart items, that allow you to restore it… So adding a confirmation notice, is not really viable and even disturbing for customer experience.