1

I'd like to change the order status string from "Completed" to "Shipped" to allow for better communication between us and the customer.

Commerce Custom Order Status would sidestep this problem by allowing me to create a new status, but that isn't the best way around it, because there might be triggers set for "completed".

0

3 Answers 3

3

The best thing for you to do would be to alter the order status info array to give the "Completed" status a new title. The example in the documentation actually demonstrates specifically how to change the title of the completed status. Look for hook_commerce_order_status_info_alter() in commerce_order.api.php.

There are ways to override strings through the user interface, but this is such a small module change that I'd really recommend directly making it in a site-specific module.

2
  • 1
    thanks! used hook_commerce_order_status_info_alter(&$order_statuses) { $order_statuses['completed']['title'] = t('Shipped'); } It worked for the user viewing in their order history, but it still shows "completed" in the admin pages (admin/commerce/orders/list). Is there away to change the name for the admin pages too, because the person who administers that might get confused
    – ashash
    Commented Jun 17, 2014 at 17:18
  • 1
    Ryan answer @ashash question please, is there any way to change in admin pages too?
    – Yuseferi
    Commented Jun 4, 2016 at 9:18
2

I would suggest adding a new order status instead of modifying the "Completed" order status, since that usually means the order is done-done-done. Something like "Pending: Shipping" (in the "Pending" order state) would make more sense given a workflow like this:

  • Pending: Pending -- The order is paid and ready for shipping.
  • Pending: Shipping* -- The order has shipped and may have a tracking number attached. *Note: You would need to add this status value in a custom module.
  • Completed: Completed -- The order was delivered, shipping has been fulfilled, no further action required by the store.

See also:

You can certainly add to the "Pending" state as suggested above for something simple. For a more detailed example, you can also have a separate "Shipping" state and statuses:

/**
 * Shipping status
 */
define('SHIPPING_PENDING', 'shipping_pending');
define('SHIPPING_SHIPPED', 'shipping_shipped');
define('SHIPPING_DELAYED', 'shipping_delayed');
define('SHIPPING_CANCELED', 'shipping_canceled');
define('SHIPPING_DELIVERED', 'shipping_delivered');

/**
 * Implements hook_commerce_order_state_info()
 */
function example_commerce_order_state_info() {
  $order_states = array();

  $order_states['shipping'] = array(
    'name' => 'shipping',
    'title' => t('Shipping'),
    'description' => t('Orders in the shipping process.'),
    'weight' => 10,
    'default_status' => SHIPPING_PENDING,
  );

  return $order_states;
}

/**
 * Implements hook_commerce_order_status_info()
 */
function example_commerce_order_status_info() {
  $order_statuses = array();

  $order_statuses[SHIPPING_PENDING] = array(
    'name' => SHIPPING_PENDING,
    'title' => t('Shipping: Pending'),
    'state' => 'shipping',
    'weight' => 1,
  );
  $order_statuses[SHIPPING_SHIPPED] = array(
    'name' => SHIPPING_SHIPPED,
    'title' => t('Shipping: Shipped'),
    'state' => 'shipping',
    'weight' => 2,
  );
  $order_statuses[SHIPPING_DELAYED] = array(
    'name' => SHIPPING_DELAYED,
    'title' => t('Shipping: Delayed'),
    'state' => 'shipping',
    'weight' => 3,
  );
  $order_statuses[SHIPPING_CANCELED] = array(
    'name' => SHIPPING_CANCELED,
    'title' => t('Shipping: Canceled'),
    'state' => 'shipping',
    'weight' => 4,
  );
  $order_statuses[SHIPPING_DELIVERED] = array(
    'name' => SHIPPING_DELIVERED,
    'title' => t('Shipping: Delivered'),
    'state' => 'shipping',
    'weight' => 5,
  );

  return $order_statuses;
}
0

You can use the drupalcommerce complete hook to change the $order status:

function hook_commerce_checkout_complete($order) {
  // insert code
}
1
  • 1
    The questioner doesn't just want to use a different status but actually wants to rename an existing one. Commented Jun 16, 2014 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.