Merge branch 'master' into persist-workflow-documents

This commit is contained in:
Almira Krdzic
2018-11-05 08:52:41 +01:00
4 changed files with 59 additions and 2 deletions

View File

@@ -22,6 +22,12 @@ class Wiaas_Order {
add_filter('woocommerce_register_post_type_shop_order', array(__CLASS__, 'manage_order_settings'));
add_filter( 'woocommerce_register_shop_order_post_statuses', array(__CLASS__, 'register_custom_order_statuses'), 10, 1);
add_filter( 'wc_order_statuses', array(__CLASS__, 'add_custom_statuses_to_list' ), 10, 1);
add_filter( 'bulk_actions-edit-shop_order', array(__CLASS__, 'add_custom_statuses_to_bulk_edit' ), 10, 1);
add_filter('woocommerce_rest_check_permissions', array( __CLASS__, 'check_order_access'), 10, 4);
add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 999, 3);
@@ -203,6 +209,51 @@ class Wiaas_Order {
return $order->get_meta('_wiaas_delivery_suppliers');
}
/**
* Register additional order statuses
*
* @param array $order_statuses
*
* @return array
*/
public static function register_custom_order_statuses($order_statuses){
// Status must start with "wc-"
$order_statuses['wc-open'] = array(
'label' => _x( 'Open', '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( 'Open <span class="count">(%s)</span>', 'Open <span class="count">(%s)</span>', 'woocommerce' ),
);
return $order_statuses;
}
/**
* display custom wiaas statuses in order status dropdown
*
* @param array $order_statuses
*
* @return array
*/
public static function add_custom_statuses_to_list($order_statuses){
$order_statuses['wc-open'] = _x( 'Open', 'Order status', 'woocommerce' );
return $order_statuses;
}
/**
* display custom wiaas statuses in bulk actions
*
* @param array $bulk_actions
*
* @return array
*/
public static function add_custom_statuses_to_bulk_edit($bulk_actions){
// Note: "mark_" must be there instead of "wc"
$bulk_actions['mark_open'] = 'Change status to open';
return $bulk_actions;
}
/**
* Update `shop_order` post type settings before creation to enable better order management for wiaas
*