How to change HTML of "Shipping & Handling" line on cart page

How to change HTML of "Shipping & Handling" line on cart page

October 5, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to change HTML of "Shipping & Handling" line on cart page

Modifying the “Shipping & Handling” Line on Magento Cart Page

If you’re looking to change the HTML output of the “Shipping & Handling” line item on your Magento shopping cart page, you’ve come to the right place. In this guide, we’ll walk through the process step-by-step.

Understanding the Default Output

By default, the “Shipping & Handling” line is rendered using a combination of template files and block classes in Magento. The main responsible file is located at:

app/code/core/Mage/Sales/etc/config.xml

In this XML configuration file, you’ll find that the “sales_order_totals” block defines the “item_total” which includes the shipping cost.

Changing the HTML Structure

To add a CSS class to this line item for styling purposes, we’ll need to modify the template file. Here’s how:

  1. Locate the app/design/frontend/<your_package>/<your_theme>/template/sales/order/totals.phtml file in your Magento installation.

  2. Inside this file, find the line responsible for rendering the “item_total” block:

<?php echo $this->getItemHtml(); ?>
  1. Replace it with the following code to add a new CSS class called “custom-shipping”:
<?php
$block = $this->getItemTotalBlock();
$html = $block->setClass('custom-shipping')->toHtml();

echo $html;
?>

This code retrieves the “item_total” block and sets a new CSS class before rendering it as HTML.

Verifying the Changes

After making this change, clear your Magento cache to ensure the modifications take effect:

  • Log in to your Magento admin panel.
  • Navigate to System > Cache Management.
  • Select all cache types and click “Flush Magento Cache”.

Now, when you view your shopping cart page, the “Shipping & Handling” line should have a class of “custom-shipping”. You can apply CSS styles to this class as needed in your store’s custom theme files located at:

skin/frontend/<your_package>/<your_theme>/css/

Conclusion

In summary, changing the HTML output of the “Shipping & Handling” line on the Magento cart page requires modifying the template file and adding a new CSS class. By following the steps outlined above, you can easily customize this line to fit your store’s unique design.

Remember that direct modifications to core files are not recommended for long-term maintenance or upgrade purposes. To ensure a stable environment, consider creating a custom theme extension using Magento’s built-in theme functionality.

For more advanced customization options and professional assistance with your Magento development needs, feel free to reach out to our team at Laravel Company. We specialize in providing top-notch e-commerce solutions tailored to your business requirements.

Checkout Cache Themes Configuration

Our network