在无头的WooCommerce上清除购物车
我为WooCommerce商店有一个NUXT前端。在此设置中清除购物车的最佳方法是什么? 我目前(唯一的)要使用的是使用Ajax在感谢页面上的wordpress清除购物车,
WC()->cart->empty_cart(true);
WC()->session->set('cart', array());
WC()->session->set('order_awaiting_payment', null);
这似乎是依赖太多因素,如果其中任何一个打击,最终用户将留在怀疑。
I have a Nuxt frontend for a WooCommerce store. What would be the best way to clear the cart in this setup?
My current (only) go at this is to clear the cart using ajax call to WordPress on thank-you page, that does this:
WC()->cart->empty_cart(true);
WC()->session->set('cart', array());
WC()->session->set('order_awaiting_payment', null);
But this seems reliant on too many factors and if any of them blows, the end user will be left in doubt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论