Created
November 7, 2018 11:59
-
-
Save danichim/0e2e139a2940d31da339599ff13606a4 to your computer and use it in GitHub Desktop.
New statuses on woocommerce orders and actions for dropdown
This file contains 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
/** | |
* Register new status refuz & verificare | |
**/ | |
function register_new_orders_status() { | |
register_post_status( 'wc-refuz', array( | |
'label' => 'Refuz comanda', | |
'public' => true, | |
'exclude_from_search' => false, | |
'show_in_admin_all_list' => true, | |
'show_in_admin_status_list' => true, | |
'label_count' => _n_noop( 'Refuzată <span class="count">(%s)</span>', 'Refuzate <span class="count">(%s)</span>' ) | |
) ); | |
register_post_status( 'wc-verificare', array( | |
'label' => 'Necesita verificare', | |
'public' => true, | |
'exclude_from_search' => false, | |
'show_in_admin_all_list' => true, | |
'show_in_admin_status_list' => true, | |
'label_count' => _n_noop( 'Necesita verificare <span class="count">(%s)</span>', 'Necesita verificare <span class="count">(%s)</span>' ) | |
) ); | |
} | |
add_action( 'init', 'register_new_orders_status' ); | |
// Add to list of WC Order statuses | |
function add_new_orders_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-refuz'] = 'Refuzata'; | |
$new_order_statuses['wc-verificare'] = 'Necesita verificare'; | |
} | |
} | |
return $new_order_statuses; | |
} | |
add_filter( 'wc_order_statuses', 'add_new_orders_to_order_statuses' ); | |
function rename_or_reorder_bulk_actions( $actions ) { | |
$actions = array( | |
'mark_refuz' => __( 'Schimbă starea la refuzată', 'textdomain' ), | |
'mark_verificare' => __( 'Schimbă starea la necesită verificare', 'textdomain' ), | |
'mark_processing' => $actions['mark_processing'], | |
'mark_on-hold' => $actions['mark_on-hold'], | |
'mark_completed' => $actions['mark_completed'], | |
'trash' => $actions['trash'], | |
'remove_personal_data' => $actions['remove_personal_data'], | |
); | |
return $actions; | |
} | |
add_filter( 'bulk_actions-edit-shop_order', 'rename_or_reorder_bulk_actions', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment