Wordpress / Woocommerce会话 [英] Wordpress/Woocommerce Sessions

查看:235
本文介绍了Wordpress / Woocommerce会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,我为使用Wordpress / Woocommerce的客户建立了一个网站。网站工作伟大,但一个问题是,篮子/会话不清除后,订单完成。对我来说,WooCommerce甚至没有标准的功能。使用Woocommece标准文件,在结帐过程完成后,最好的办法是结束会话?

Good afternoon, I have built a website for me client using Wordpress/Woocommerce. the site works great but one problem is that the basket/session doesn't clear after the order is finished. It looks to me that WooCommerce doesn't even have the feature as standard. Working with the Woocommece standard files, whats the best way to kill a session after the checkout process is complete?

有办法解决这个问题吗?

Is there a way around this?

推荐答案

您的购物车应在结帐后清算,否则可能出现其他错误。

Your cart should be clearing after checkout so something else may be wrong.

创建一个包含 empty_cart()的函数,该函数在付款完成时触发(仅限大小写)。
请参阅: http://docs.woothemes.com/wc-apidocs /class-WC_Cart.html

You could create a function with empty_cart() in it that is triggered when payment is complete "just in case". See: http://docs.woothemes.com/wc-apidocs/class-WC_Cart.html

add_filter( 'woocommerce_payment_complete_order_status', 'pg_woocommerce_payment_complete_order_status', 10, 2 );
function pg_woocommerce_payment_complete_order_status ( $order_status, $order_id ) {

    $global $woocommerce;
    $woocommerce->cart->empty_cart();

}

这篇关于Wordpress / Woocommerce会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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