Skip to content

Instantly share code, notes, and snippets.

@jfeliweb
Created February 25, 2020 04:03
Show Gist options
  • Save jfeliweb/20571170dcc2526b0b432273afda880c to your computer and use it in GitHub Desktop.
Save jfeliweb/20571170dcc2526b0b432273afda880c to your computer and use it in GitHub Desktop.
Create New Order Status in WooCommerce
//Step 1: Register the new order status
add_action( 'init', 'pf_register_order_statuses' );
function pf_register_order_statuses() {
register_post_status( 'wc-processing-ss', array(
'label' => 'Processing - ShipStation',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Processing - ShipStation <span class="count">(%s)</span>', 'Processing - ShipStation <span class="count">(%s)</span>' )
) );
}
//Setp 2: Add the new order status to the list of order statuses
add_filter( 'wc_order_statuses', 'pf_order_statuses' );
function pf_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-processing-ss'] = 'Processing - ShipStation';
}
}
return $new_order_statuses;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment