2
votes

The Magento checkout has a line that show the totals in the file:

frontend/base/default/template/checkout/onepage/review/info.phtml

<?php echo $this->getChildHtml('totals'); ?>

But this line shows also the shipping method if customer choose a freight method and I didn't find this to take it of my total page, I know that I can't delete it from the database because this information is used in the freight choice.

If someone knows I would stay very gratified

Thanks by now

2

2 Answers

3
votes

For removing this data from the total you need to override the following classes:

To hide it in shopping cart page:

Mage_Sales_Model_Quote_Address_Total_Shipping::fetch() method needs to be overridden via custom module:

public function fetch(Mage_Sales_Model_Quote_Address $address)
{
    $originalShippingDescription = $address->getShippingDescription(); // Keep old description value
    $address->unsShippingDescription(); // Removes description of shipping method
    parent::fetch($address);
    $address->setShippingDescription($originalShippingDescription); // Sets back original description of shipping method
    return $this;
}

To hide it on order overview pages in the user account, you need to perform another customization of Mage_Sales_Block_Order_Totals class. For this purpose you need to create a new block extended from Mage_Core_Block_Abstract

  1. Create block in some your custom module

    <?php 
    class Custom_Module_Block_Shipping_Total extents Mage_Core_Block_Abstract
    {
        public function initTotals()
        {
            if ($this->getParentBlock() && $this->getParentBlock()->getTotal('shipping')) {
               $this->getParentBlock()->getTotal('shipping')->setLabel($this->__('Shipping & Handling'));
            }
        }
    }
    
  2. Add layout updates to include you block into order view.

     <layout>
     <!-- Your custom total on invoices view -->
        <custom_invoice_totals>
            <reference name="invoice_totals">
                <block name="custom_total" type="custom_module/shipping_total" />
            </reference>
        </custom_invoice_totals>
    
        <!-- Your custom total on shipments view -->
        <custom_shipment_totals>
            <reference name="shipment_totals">
                <block name="custom_total" type="custom_module/shipping_total" />
            </reference>
        </custom_shipment_totals>
    
        <!-- Your custom total on creditmemos view -->
        <custom_creditmemo_totals>
            <reference name="creditmemo_items">
                <block name="custom_total" type="custom_module/shipping_total" />
            </reference>
        </custom_creditmemo_totals>
    
    
        <!-- Applying your handles to particular pages in customer account -->
        <sales_order_view>
            <update handle="custom_order_totals" />
        </sales_order_view>
    
        <sales_order_print>
            <update handle="custom_order_totals" />
        </sales_order_print>
    
        <sales_email_order_items>
            <update handle="custom_order_totals" />
        </sales_email_order_items>
    
        <!-- applies your total in email -->
        <sales_email_order_items>
            <update handle="custom_order_totals" />
        </sales_email_order_items>
    
        <sales_guest_view>
            <update handle="custom_order_totals" />
        </sales_guest_view>
    
        <!-- invoice pages -->
        <sales_order_invoice>
            <update handle="custom_invoice_totals" />
        </sales_order_invoice>
    
        <sales_order_printinvoice>
            <update handle="custom_invoice_totals" />
        </sales_order_printinvoice>
    
        <sales_email_order_invoice_items>
            <update handle="custom_invoice_totals" />
        </sales_email_order_invoice_items>
    
        <sales_guest_invoice>
            <update handle="custom_invoice_totals" />
        </sales_guest_invoice>
    
        <!-- shipment pages -->
        <sales_order_shipment>
            <update handle="custom_shipment_totals" />
        </sales_order_shipment>
    
        <sales_order_printshipment>
            <update handle="custom_shipment_totals" />
        </sales_order_printshipment>
    
        <sales_email_order_shipment_items>
            <update handle="custom_shipment_totals" />
        </sales_email_order_shipment_items>
    
        <sales_guest_shipment>
            <update handle="custom_shipment_totals" />
        </sales_guest_shipment>
    
        <!-- creditmemo pages -->
        <sales_order_creditmemo>
            <update handle="custom_creditmemo_totals" />
        </sales_order_creditmemo>
    
        <sales_order_printcreditmemo>
            <update handle="custom_creditmemo_totals" />
        </sales_order_printcreditmemo>
    
        <sales_email_order_creditmemo_items>
            <update handle="custom_creditmemo_totals" />
        </sales_email_order_creditmemo_items>
    
        <sales_guest_creditmemo>
            <update handle="custom_creditmemo_totals" />
        </sales_guest_creditmemo>
     </layout>
    

After such customization on all pages on the frontend your shipping total will be without information about shipping method...

0
votes

in your local cart.phtml, use following snippet:

<div class="cart-totals-wrapper">
    <div class="cart-totals">
        <div class="cart-totals-container">
            <!-- <?php echo $this->getChildHtml('totals'); ?> -->
            <?php 
                $_quote = Mage::getSingleton('checkout/session')->getQuote();
                $_cartValue = 0;
                $_items = $_quote->getAllItems();
                foreach ($_items as $_item) {
                    $_cartValue += $_item->getRowTotalInclTax();
                }
            ?>
            <table id="shopping-cart-totals-table">
                <colgroup>
                    <col>
                    <col width="1">
                </colgroup>
                <tbody>
                <tr>
                    <td class="a-right" colspan="1" style=""><?php echo $this->__('Subtotal'); ?></td>
                    <td class="a-right" style="">
                        <span class="price"><?php echo $_quote->getStore()->formatPrice($_cartValue); ?></span>
                    </td>
                </tr>
            </table>
            <p class="message"><?php echo $this->__('Shipping will be calculated at checkout'); ?></p>
        </div>