Tuesday 20 January 2015

Drupal 7 commerce can i remove order statuses

The Situation:

I have a role of 'Sales Manager' - they have access to manage the orders.

On the dropdown for Order statuses I can see the following . 



What I'd like to do though is limit this to - Pending, Process and Completed.

To fix this the following code works a treat.

/***
 * Implements hook_commerce_order_status_info_alter
 */


function my_commerce_patch_commerce_order_status_info_alter(&$order_statuses){

 global $user;

  if (in_array('sales manager', $user->roles)) {
    unset($order_statuses['cart']);
    unset($order_statuses['checkout_checkout']);
    unset($order_statuses['checkout_shipping']);
    unset($order_statuses['checkout_review']);
    unset($order_statuses['checkout_payment']);
    unset($order_statuses['checkout_complete']);
  }

}

No comments: