Last active
September 21, 2019 18:57
-
-
Save kirillrocks/910cfef9a2f7236970cc41b4fe2d8c04 to your computer and use it in GitHub Desktop.
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
add_action( 'woocommerce_payment_complete', 'simon_payment_complete' ); | |
function simon_payment_complete( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
$items = $order->get_items(); | |
$product_ids_to_check = [ 123, 345 ]; // product ids you want to check against | |
foreach ( $items as $item ) { | |
if ( in_array( $item->get_product_id(), $product_ids_to_check ) ) { | |
$order->update_status( 'pending', 'order_note' ); // order note is optional, if you want to add a note to order | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment