Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

php - How to remove WooCommerce order status?

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...