Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

php - Wordpress/Woocommerce Sessions

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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();

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...