Ako povoliť úpravu objednávok a vytvoriť nový status

Povolenie editovania objednávok v stave spracováva sa / processing

 // Allow editing processingorders
 add_filter( 'wc_order_is_editable', 'wc_make_processing_orders_editable', 10, 2 );
 function wc_make_processing_orders_editable( $is_editable, $order ) {
     if ( $order->get_status() == 'processing' ) {
         $is_editable = true;
     }
 
     return $is_editable;
 }

Vytvorenie nového stavu objednávky

add_filter( 'woocommerce_register_shop_order_post_statuses', 'register_custom_order_status' );
function register_custom_order_status( $order_statuses ){
    
    $order_statuses['wc-custom-status'] = array(                                 
      'label'                     => _x( 'Moj novy stav', 'Order status', 'woocommerce' ),
      'public'                    => false,                                 
      'exclude_from_search'       => false,                                 
      'show_in_admin_all_list'    => true,                                 
      'show_in_admin_status_list' => true,                                 
      'label_count'               => _n_noop( 'Moj novy stav <span class="count">(%s)</span>', 'Moj novy stav <span class="count">(%s)</span>', 'woocommerce' ),                              
    );      
    return $order_statuses;
}

add_filter( 'wc_order_statuses', 'show_custom_order_status' );
function show_custom_order_status( $order_statuses ) {      
   $order_statuses['wc-custom-status'] = _x( 'Moj novy stav', 'Order status', 'woocommerce' );       
   return $order_statuses;
}
 
add_filter( 'bulk_actions-edit-shop_order', 'custom_order_status_bulk' );
function custom_order_status_bulk( $bulk_actions ) {
   
    $bulk_actions['mark_custom-status'] = 'Change status to Moj novy stav';
    return $bulk_actions;
  }

Pridaj komentár

Vaša e-mailová adresa nebude zverejnená. Vyžadované polia sú označené *