Avishay28
Avishay28

Reputation: 2456

Woocommerce - Add another custom status so it will make the order "editable"

I created another custom statuses to wc statuses, and I want this status to leave the order "editable", so I found this code in the file abstract-wc-order.php:

public function is_editable() {
        return apply_filters( 'wc_order_is_editable', in_array( $this->get_status(), array( 'pending', 'on-hold', 'auto-draft', 'failed' ) ), $this );
    }

Now if I understand currently, I need to add my custom status to the array above, but I'm not really sure how to do this - to add my status to the above array by hooking the filter wc_order_is_editable, I will really appreciate to any help!

Upvotes: 0

Views: 1458

Answers (1)

helgatheviking
helgatheviking

Reputation: 26319

Probably something like this will work:

function so_39193164_is_editable( $editable, $order ) {
    if( $order->get_status() == 'your-new-status' ){
        $editable = true;
    }
    return $editable;
}
add_filter( 'wc_order_is_editable', 'so_39193164_is_editable', 10, 2 );

If the order status is your new status then $editable will be true. If not, it will be whatever WooCommerce already decided in the is_editable() method.

Upvotes: 3

Related Questions