Created
September 18, 2014 00:20
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?