I registered few custom post statuses. And i wanna hook it when order received.
i try it by:
add_action('woocommerce_checkout_order_processed', 'aa_func_20151609121636',30, 2);
function aa_func_20151609121636($order_id, $posted)
{
global $wpdb;
$post_status = null;
if(isset($_POST['yes_its_enq']) && ($_POST['yes_its_enq'] === 'yes')) {
$post_status = 'wc-gibraenquiry';
} else {
$post_status ='wc-gibrapending';
}
$wpdb->update( $wpdb->posts, array( 'post_status' => $post_status ), array( 'ID' => $order_id ) );
}
but i failled and post status is wc-processing
What the right hook for it?
Use the
update_status
method of WC_Order class to update the status.Try the following code: