I have separate taxes set up for products and shipping on a customer site. The tax on shipping could be different than the tax on the products depending on where the product is being shipped to.

On the order summary on my checkout screen I see:

Subtotal
Tax
Shipping Tax
Shipping Charge ('Regular' in the attached image)
Order Total

Does someone know how to customize the order of the line items on the checkout form? Ideally I would like to see the Shipping Tax line item appear below the shipping charge, or at the very least have the shipping charge immediately below the subtotal so the taxes appear after the item they're applied to. The rules all work correctly. The calculations are correct, I would just like to change the order of the line items so it is more in line with what shoppers would expect to see. Having tax on shipping appear above the shipping line item does not make a lot of sense. Thanks in advance.

CommentFileSizeAuthor
checkout.jpg25.07 KBjmoruzi

Comments

rszrama’s picture

Status: Active » Closed (fixed)

The only way to do this right now as far as I know is to adjust the price component type weights through hook_commerce_price_component_type_info_alter(). What you're seeing aren't line items but price components of the order total price field.

jmoruzi’s picture

Thanks Ryan, that was exactly what I was looking for.

I wrote a very small custom module to implement this. I never wrote a module before and I was surprised how easy it was. The hard part was finding out the weights of the other price components because I didn't know where to look. The weight of the shipping component is 20 from the commerce_shipping.module line 129 so in my module I made the tax on shipping 30. That's it. Now the shipping tax appears below the shipping price. Here's the code from my module. Hope this helps someone else.

<?php

/**
 * Implements hook_commerce_price_component_type_info_alter()
 **/
 
function price_component_sort_commerce_price_component_type_info_alter(&$components) {
  if (!empty($components['tax|tax_on_shipping'])) {
    $components['tax|tax_on_shipping']['weight'] = 30;
  }
}
rszrama’s picture

Awesome, glad you got it sorted out.