Hi Guys,
This article will showcase on updating order status when our webhook received paid_out or Confirmed status from the gocardless .
Note: This will be applicable if you are using WooCommerce gocardless plugins on your WordPress environment.
//add gocardless pending submission status when direct debit payment is completed add_filter( 'woocommerce_payment_complete_order_status_processing', 'update_gocardless_status_when_payment_complete' ); /** * @param int $order_id order id * @return string */ function update_gocardless_status_when_payment_complete( $order_id ) { $order = wc_get_order( $order_id ); $payment_gateway = $order->get_payment_method(); if( "gocardless" === $payment_gateway ) { $order->set_status( 'completed' ); $order->save(); } }
Let me know if you have any question or queries, I would be more than happy to help you.
Thanks
Thanks for this code snippet. Is it required for this to be a “public” function?
LikeLike
Hi John,
Sorry, public shouldn’t be there. Just corrected the snippet. Thanks for letting me know on this,
LikeLike
Thanks for the clarification. Out of interest why did you decide to use the filter rather than hooking
into the action ‘woocommerce_payment_complete’
https://github.com/jrick1229/woocommerce-subscriptions-auto-complete-orders/blob/master/wcs-auto-complete-order.php
LikeLike
@john Hi john, Gocardless plugin doesn’t enter into pending status, hence gocardless start with processing status, which is the reason we are using processing hooks in there. You can refer the code here: https://sushilwp.files.wordpress.com/2019/07/woo-hooks.png
Thanks
LikeLike
Hello Sushil, Great little snippet, saved me hours! Is it possible to update the Wooccommerce status when the GoCardless hook is ‘paid-out?’
LikeLike
Where do you place this code?
LikeLike
Hi Jonny, you can place anywhere on your functions.php
LikeLike