Created
August 1, 2017 22:50
-
-
Save wsenjer/094a24ff3e7ff0616665c4deb92444d8 to your computer and use it in GitHub Desktop.
Change WC order status
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 | |
function my_change_status_function() { | |
global $wp; | |
if ( ! empty( $wp->query_vars['order-received'] ) ) { | |
$order_id = absint( $wp->query_vars['order-received'] ); | |
$order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : ''; | |
if ( $order_id > 0 ) { | |
$order = wc_get_order( $order_id ); | |
if ( $order && $order->get_order_key() === $order_key ) { | |
$order->update_status('completed'); | |
} | |
} | |
} | |
} | |
add_action( 'init', 'my_change_status_function' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment