Reputation: 780
I am making a simple e-commerce website using WooCommerce plugin on Wordpress. I am using Paypal as my payment gateway. When user is purchasing product from my store and give payment successfully, WooCommerce should automatically change order status from 'pending'
to 'completed'
, but it is not changing order status.
How can I achieve this?
Upvotes: 2
Views: 2226
Reputation: 253978
This is a snippet code (that you can find in wooCommerce docs):
/** * Auto Complete all WooCommerce orders. */ add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order'); function custom_woocommerce_auto_complete_order( $order_id ) { if ( ! $order_id ) { return; } $order = wc_get_order( $order_id ); $order->update_status( 'completed' ); }
But this snippet does not work for "BACS", "Pay on delivery" and "Cheque" payment methods. It's ok for Paypal and Credit Card gateways payment methods.
There is also a wordpress (woocommerce) free plugin working with all payment methods except some others Credit Card gateways payment methods:
Auto complete paid Orders (depending on Payment methods)
WooThemes - WooCommerce Autocomplete Orders
Regards
Upvotes: 3