Skip to content

Instantly share code, notes, and snippets.

@bryceadams
Created July 4, 2016 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bryceadams/3ecd45896fe861e3c33ab075f316b7c8 to your computer and use it in GitHub Desktop.
Save bryceadams/3ecd45896fe861e3c33ab075f316b7c8 to your computer and use it in GitHub Desktop.
<?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