Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created September 18, 2014 00:20
Show Gist options
  • Select an option

  • Save ChromeOrange/3cb3a16a6560795b972d to your computer and use it in GitHub Desktop.

Select an option

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>';
}
@andycaps

Copy link
Copy Markdown

I used the above code and it deleted a record?

I changed the code to:

'wp-backorders' to 'waitingforshipping'
'Back Orders' to 'Waiting for Shipping'
'function backorder_font_icon' to 'function waitingforshiping_font_icon'

The dropdown worked great but when I updated from processing to waiting for shipping the record disappeared. Luckily I had an original copy of the order so was able to reenter the order.

What did I do wrong????

Oh by the way - not sure where the code went so put it at the very bottom of the existing code - is it that I did wrong?

@lightson

lightson commented Oct 5, 2015

Copy link
Copy Markdown

Very useful snippet, thanks.

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