Last active
November 27, 2019 04:24
-
-
Save Rocky-Mehta88/cce28f67f5496a9cfa0964d1835607dd to your computer and use it in GitHub Desktop.
All Order Status "Completed" after Payment in woocommerce.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Rocky Mehta | |
* Link: https://rocky-mehta.com/ | |
* Email: rocky.mehta88@gmail.com | |
* All Order Status = "Completed" ( WooCommerce 2.2+ ) | |
*/ | |
add_action('woocommerce_thankyou', 'obw_all_orders_completed_function'); | |
function obw_all_orders_completed_function() { | |
global $woocommerce; | |
if (!$order_id) | |
return; | |
$order = new WC_Order($order_id); | |
$order->update_status('completed'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Rocky Mehta | |
* Link: https://rocky-mehta.com/ | |
* Email: rocky.mehta88@gmail.com | |
* All Paid Order Status = "Completed" after Payment ( WooCommerce 2.2+ ) | |
*/ | |
add_filter( 'woocommerce_payment_complete_order_status', 'obw_paid_orders_function' ); | |
function obw_paid_orders_function( $order_status, $order_id ) { | |
$order = wc_get_order( $order_id ); | |
if ( $order_status == 'processing' && ( $order->status == 'on-hold' || $order->status == 'pending' || $order->status == 'failed' ) ) { | |
return 'completed'; | |
} | |
return $order_status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment