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' => t('Shipping'),
'weight' => 20,
);
// Add a price component type for each shipping service that specifies it.
foreach (commerce_shipping_services() as $name => $shipping_service) {
if ($shipping_service['price_component'] && empty($components[$shipping_service['price_component']])) {
$components[$shipping_service['price_component']] = array(
'title' => $shipping_service['title'],
'display_title' => $shipping_service['display_title'],
'shipping_service' => $name,
'weight' => 20,
);
}
}
return $components;
}
PS. Tax rate on shipping price is not the same as my problem. DS.