how to remove failed orders auto
-
You can set all that in settings now.
unfortunately I can not find
i want to remove orders instant if is failed
Why? What if the customer is still in the process of purchasing? You’re going to make them start all over? That’s not a good customer experience at all.
my payment module and mercanet (module of my bank)
I use woocommerce with a reservation system for places in a boat, if an order is not paid, the places remains blocked.
I need to delete the commands failed to be able to unlock the places to lock
I just need to do:
if order = failed -> delete orderGot it.
Maybe see if this works for you.
https://ww.wp.xz.cn/plugins/woo-cancel-abandoned-order/If that doesn’t work for you you might want to test this. I’ve set it to delete in one minute.
add_action( 'woocommerce_order_status_failed', 'the_serafin_woocommerce_auto_delete_order' ); function the_serafin_woocommerce_auto_delete_order( $order_id ) { // 5*60 = 300 seconds. Here 1minute = 60 seconds. wp_schedule_single_event(tim() + 300, 'the_serafin_main_delete_event', $order_id); } function the_serafin_main_delete_event( $order_id ) { global $woocommerce; $order = new WC_Order( $order_id ); $order_status = $order->get_status(); if ( !$order_id ) return false; if ('cancelled' == $order_status || 'failed' == $order_status || 'pending' == $order_status ) { wp_delete_post($order_id,true); return true; } return false; }oh thx
the plugins not work for me i have already teston my fuction.php ?
Yes, on your functions file. Advise not to add thru Editor. Use FTP if at all possible.
yes
i go try thx youWelcome
I just added the code in my function.php but the oders remains Failed
https://i.gyazo.com/8a63d9843451040c85b573114b03dc4d.png
code :
https://i.gyazo.com/b2e18808033d76e91c7498b86ceccb98.png
-
This reply was modified 7 years, 1 month ago by
tom80550.
I reviewed latest in wc post data. Maybe I’m missing something. I’ll ask my partner if he has any idea.
I rewrote it as well
add_action( 'woocommerce_order_status_failed', 'woocommerce_auto_delete_order' ); function woocommerce_auto_delete_order( $order_id ) { // 5*60 = 300 seconds. Here 1 minute = 60 seconds. wp_schedule_single_event(tim() + 60, 'main_delete_event', $order_id); } function main_delete_event( $order_id ) { global $woocommerce; $order = new WC_Order( $order_id ); $order_status = $order->get_status(); if ( !$order_id ) return false; if ('failed' == $order_status ) { wp_delete_post($order_id,true); return true; } return false; }I can’t test on local right now. Sorry. Forgot my demo login creds.
Sorry forgot to add an action. Hope you didn’t see yet. Now is good.
thx for your help
but the orders remain in the list
ttps://i.gyazo.com/5f6969ee857a9bee17996541017f4fe9.png -
This reply was modified 7 years, 1 month ago by
The topic ‘how to remove failed orders auto’ is closed to new replies.