• Hi I have a paid version of Custom Order Status.

    In my functions.php file if the user pays I’m trying to set the status to a custom status in these hooks.

    It does return those values correctly (i.e. the if statement is satisfied) but the order status never gets updated:

    add_action( ‘woocommerce_payment_complete’, ‘so_payment_complete’ );
    function so_payment_complete($order_id){
    $order = new WC_Order($order_id);
    if($order->has_shipping_method(‘uk_flat_rate’) || $order->has_shipping_method(‘uk_free’)) {
    //update order status to UK Status
    $order->update_status(‘uk-status’,”,true);
    }
    }

    add_filter(‘woocommerce_payment_complete_order_status’, ‘so_update_order_status’, 10, 2);

    function so_update_order_status( $order_status, $order_id ) {
    $order = new WC_Order($order_id);
    if(($order->has_shipping_method(‘uk_flat_rate’) || $order->has_shipping_method(‘uk_free’)) && $order->get_status() != ‘uk-status’) {
    //update order status to UK Status
    return ‘uk-status’;
    }
    return $order_status;
    }

    Regardless of either of these methods being hit the order status is always set to On Hold instead of the defined custom status.

    Any ideas why?

  • The topic ‘Order status won’t update to custom status’ is closed to new replies.