Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to modify a function contained in woocommerce. This is my edited function (woocommerce/includes/wc-order-functions.php):

function wc_get_order_statuses() {
    $order_statuses = array(
        'wc-pending'    => _x( 'Pending Payment', 'Order status', 'woocommerce' ),
        /*'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),*/
        'wc-on-hold'    => _x( 'On Hold', 'Order status', 'woocommerce' ),
        'wc-completed'  => _x( 'Completed', 'Order status', 'woocommerce' ),
        'wc-cancelled'  => _x( 'Cancelled', 'Order status', 'woocommerce' ),
        'wc-refunded'   => _x( 'Refunded', 'Order status', 'woocommerce' ),
        'wc-failed'     => _x( 'Failed', 'Order status', 'woocommerce' ),
    );
    return apply_filters( 'wc_order_statuses', $order_statuses );
}

I tried to load a new function within the function.php file in the child theme, but does not seem to work.

what I want to achieve is to eliminate the order item "Processing" from the status menu. I also tried with css but those do not support

select option[value="wc-processing"] {display: none !important;}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
462 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to use filters. Once upon a time, I wrote what I think is a good tutorial explaining WordPress filters

In this case, the end result would be:

function so_39252649_remove_processing_status( $statuses ){
    if( isset( $statuses['wc-processing'] ) ){
        unset( $statuses['wc-processing'] );
    }
    return $statuses;
}
add_filter( 'wc_order_statuses', 'so_39252649_remove_processing_status' );

Keep in mind, that the processing status is the default status when an order is created, so you may have to make other changes to compensate for it's removal.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...