Modify price components from Commerce Shipping without altering the module itself I use Drupal Commerce with Commerce Shipping and Commerce Flat Rate.

I have a client who wants the shipping line item in the commerce summary cart to come before the tax line item. My problem lies in that Commerce Shipping doesn't expose the weight of each shipping service when it implements the hook_commerce_price_component_type_info as seen below.

I have tried to use the mentioned hook in one of my own modules and with a lower value for the weight. This produces an error in the Commerce Price module where it tries to do the addition array(20, -50) + 1. Somehow, the Commerce Price module creates an array of the values instead of overwriting.

The weight I'm trying to overwrite is the one in the foreach loop.

Once I have solved this, I'll need to subtract the tax component on the shipping line item, but that's another problem which I can probably figure out by myself.

Line 110 to 135 in commerce_shipping.module.

/**
 * Implements hook_commerce_price_component_type_info().
 */
function commerce_shipping_commerce_price_component_type_info() {
  $components = array();

  // Define a generic shipping price component type.
  $components['shipping'] = array(
    'title' =&gt; t('Shipping'),
    'weight' =&gt; 20,
  );

  // Add a price component type for each shipping service that specifies it.
  foreach (commerce_shipping_services() as $name =&gt; $shipping_service) {
    if ($shipping_service['price_component'] &amp;&amp; empty($components[$shipping_service['price_component']])) {
      $components[$shipping_service['price_component']] = array(
        'title' =&gt; $shipping_service['title'],
        'display_title' =&gt; $shipping_service['display_title'],
        'shipping_service' =&gt; $name,
        'weight' =&gt; 20,
      );
    }
  }

  return $components;
}


PS. Tax rate on shipping price is not the same as my problem. DS.
If I get you correctly, you want to alter the order in where this components are displayed in the checkout process.

What I've done for minor tweaks on this area is using a preprocess of the components theme function, for example:

function mymodule_preprocess_commerce_price_formatted_components(&amp;$variables) {
}


There you've got $variables and all the components, including the shipping ones so you can tweak some things of the display.