How to Add Order Status in WooCommerce » NJENGAH

PHOTO EMBED

Thu Sep 09 2021 03:56:15 GMT+0000 (UTC)

Saved by @GoldieMR

/**

             Adding custom status

*/




function register_shipment_arrival_order_status() {

    register_post_status( 'wc-arrival-shipment', array(

        'label'                     => 'Shipment Arrival',

        'public'                    => true,

        'show_in_admin_status_list' => true,

        'show_in_admin_all_list'    => true,

        'exclude_from_search'       => false,

        'label_count'               => _n_noop( 'Shipment Arrival <span class="count">(%s)</span>', 'Shipment Arrival <span class="count">(%s)</span>' )

    ) );

}

add_action( 'init', 'register_shipment_arrival_order_status' );

function add_awaiting_shipment_to_order_statuses( $order_statuses ) {

    $new_order_statuses = array();

    foreach ( $order_statuses as $key => $status ) {

        $new_order_statuses[ $key ] = $status;

        if ( 'wc-processing' === $key ) {

            $new_order_statuses['wc-arrival-shipment'] = 'Shipment Arrival';

        }

    }

    return $new_order_statuses;

}

add_filter( 'wc_order_statuses', 'add_awaiting_shipment_to_order_statuses' );
content_copyCOPY

https://njengah.com/add-order-status-custom-woocommerce/