Freelance of Dev biznet
6/18/2019 - 2:14 PM

Custom order status

Création d'un status de commande personnalisé dans WooCommerce.

<?php
  add_action( 'init', 'register_my_new_order_statuses' );
  function register_my_new_order_statuses() {
      register_post_status( 'wc-shipped', array(
          'label'                     => 'Livrée',
          'public'                    => true,
          'exclude_from_search'       => false,
          'show_in_admin_all_list'    => true,
          'show_in_admin_status_list' => true,
          'label_count'               => _n_noop( 'Livrée <span class="count">(%s)</span>', 'Livrées <span class="count">(%s)</span>', 'woocommerce' )
      ) );
  }
  
  add_filter( 'wc_order_statuses', 'my_new_wc_order_statuses' );
  function my_new_wc_order_statuses( $order_statuses ) {
      $order_statuses['wc-shipped'] = 'Livrée';
  
      return $order_statuses;
  }
?>