Created
July 4, 2016 08:48
-
-
Save bryceadams/3ecd45896fe861e3c33ab075f316b7c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Autocomplete Paid Orders (WC 2.2+) | |
*/ | |
add_filter( 'woocommerce_payment_complete_order_status', 'bryce_wc_autocomplete_paid_paypal_orders' ); | |
function bryce_wc_autocomplete_paid_paypal_orders( $order_status, $order_id ) { | |
$order = wc_get_order( $order_id ); | |
if ( $order->payment_method == 'paypal' ) { | |
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