Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created September 18, 2014 00:20
Show Gist options
  • Save ChromeOrange/3cb3a16a6560795b972d to your computer and use it in GitHub Desktop.
Save ChromeOrange/3cb3a16a6560795b972d to your computer and use it in GitHub Desktop.
Add custom order status to WooCommerce 2.2, add to theme functions.php
/**
* Add custom status to order list
*/
add_action( 'init', 'register_custom_post_status', 10 );
function register_custom_post_status() {
register_post_status( 'wc-backorder', array(
'label' => _x( 'Back Order', 'Order status', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Back Order <span class="count">(%s)</span>', 'Back Order <span class="count">(%s)</span>', 'woocommerce' )
) );
}
/**
* Add custom status to order page drop down
*/
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
$order_statuses['wc-backorder'] = _x( 'Back Order', 'Order status', 'woocommerce' );
return $order_statuses;
}
/**
* Add order status icon CSS
*/
add_action('admin_head', 'backorder_font_icon');
function backorder_font_icon() {
echo '<style>
.widefat .column-order_status mark.backorder:after{
font-family:WooCommerce;
speak:none;
font-weight:400;
font-variant:normal;
text-transform:none;
line-height:1;
-webkit-font-smoothing:antialiased;
margin:0;
text-indent:0;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
text-align:center;
}
.widefat .column-order_status mark.backorder:after{
content:"\e012";
color:#ff0000;
}
</style>';
}
@lightson
Copy link

lightson commented Oct 5, 2015

Very useful snippet, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment