Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kirillrocks/910cfef9a2f7236970cc41b4fe2d8c04 to your computer and use it in GitHub Desktop.
Save kirillrocks/910cfef9a2f7236970cc41b4fe2d8c04 to your computer and use it in GitHub Desktop.
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