Skip to content

Instantly share code, notes, and snippets.

@PCianes
Last active July 8, 2017 19:46
Show Gist options
  • Save PCianes/c5a7b3d371e20d8e69744d1b3ee1a1c9 to your computer and use it in GitHub Desktop.
Save PCianes/c5a7b3d371e20d8e69744d1b3ee1a1c9 to your computer and use it in GitHub Desktop.
Adding a WooCommerce Custom Order Status
<?php
/**
* Adds icons for any custom order statuses
**/
add_action( 'wp_print_scripts', 'pc_add_custom_order_status_icon' );
function pc_add_custom_order_status_icon() {
if( ! is_admin() ) {
return;
}
?> <style>
/* Add custom status order icons */
.column-order_status mark.awaiting-shipment,
.column-order_status mark.building {
content: url(/wp-content/uploads/2014/10/CustomOrderStatus.png);
}
</style> <?php
}
<?php
/**
* Register new status
**/
function register_awaiting_shipment_order_status() {
register_post_status( 'wc-awaiting-shipment', array(
'label' => 'Awaiting shipment',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Awaiting shipment <span class="count">(%s)</span>', 'Awaiting shipment <span class="count">(%s)</span>' )
) );
}
add_action( 'init', 'register_awaiting_shipment_order_status' );
// Add to list of WC Order statuses
function add_awaiting_shipment_to_order_statuses( $order_statuses ) {
$new_order_statuses = array();
// add new order status after processing
foreach ( $order_statuses as $key => $status ) {
$new_order_statuses[ $key ] = $status;
if ( 'wc-processing' === $key ) {
$new_order_statuses['wc-awaiting-shipment'] = 'Awaiting shipment';
}
}
return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_awaiting_shipment_to_order_statuses' );
@PCianes
Copy link
Author

PCianes commented Jul 8, 2017

.widefat .column-order_status mark.re-opened::after {
content: "\e018";
color: #ffba00;
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;
}

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