PHP woocommerce_payment_complete_order_status Examples

Today, We want to share with you woocommerce_payment_complete_order_status.In this post we will show you woocommerce_payment_complete_order_status filter, hear for woocommerce change order status programmatically we will give you demo and example for implement.In this post, we will learn about woocommerce_payment_complete Hooks with an example.

woocommerce change order status after payment

WooCommerce: Automatically Complete Processing Orders

/**
 * @snippet       Programmatically Check woocommerce_payment_complete_order_status
 * @how-to        Get Pakainfo.com FREE
 * @author        Welcome To Pakainfo
 * @testedwith    WooCommerce 3.8
 * @donate $10     https://www.pakainfo.com/woocommerce-product-publish-update-and-delete-hooks/
 */
 
add_filter( 'woocommerce_payment_complete_order_status', 'pakainfo_autocomplete_processing_orders', 9999 );
 
function pakainfo_autocomplete_processing_orders() {
   return 'completed';
}

woocommerce_payment_complete Calling

here php code to update woocommerce order status after payment all the process complete as well as redirect to store

add_action( 'woocommerce_payment_complete', 'pakainfo_change_status_function' );

function pakainfo_change_status_function( $order_id ) {

    $order = wc_get_order( $order_id );
    $order->update_status( 'completed' );

}

WooCommerce – Automatically set order status after payment is received

add_filter( 'woocommerce_payment_complete_order_status', 'pakainfo_update_order_status', 10, 2 );
 
function pakainfo_update_order_status( $order_status, $order_id ) {
 
 $order = new WC_Order( $order_id );
 
 if ( 'processing' == $order_status && ( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
 
 return 'completed';
 
 }
 
 return $order_status;
}

I hope you get an idea about woocommerce_payment_complete_order_status.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment