8

In the Magento default theme's cart page we see the following totals box towards the right mid of the screen: alt text

I want to modify the labels of the 5 fields in the above box, and I have been able to change the Grand Totals, by overriding the following design file:

/html/app/design/frontend/default/mine/template/tax/checkout/grandtotal.phtml

So, now it looks like this:

alt text

My Problem is to:

Change the labels for other 3 fields in the box, and the label of a discount box that appears there if a discount applies. I have spent some time grepping through other design files, but couldn't find any. It might be some classes to override, but I haven't been able to locate them either.

I am using Magento 1.4.1.1

UPDATE 1: After turning on template path hints, following are template paths for Cart

Subtotal: app/design/frontend//tax/checkout/subtotal.phtml

Total: app/design/frontend//checkout/total/default.phtml

GrandTotal: app/design/frontend//tax/checkout/grandtotal.phtml

Tax: app/design/frontend//tax/checkout/tax.phtml

Checkout

Same as for cart and the following additional one for

Shipping: app/design/frontend//tax/checkout/shipping.phtml

But when one goes into these template files, no labels are found except in grandtotal.phtml.

I found the solution to the problem, which I have mentioned in my own answer.

This question originally asked for help on two separate problems. I posted the other one later as another question.

Community
  • 1
  • 1
Ozair Kafray
  • 13,351
  • 8
  • 59
  • 84

6 Answers6

6

Why don't you change the labels with inline translator or in locale files?

 grep 'Grand Total'  app/locale/ -rsn

app/locale/en_US/Mage_Tax.csv:55:"Grand Total (Excl. Tax)","Grand Total (Excl. Tax)" app/locale/en_US/Mage_Tax.csv:56:"Grand Total (Excl.Tax)","Grand Total (Excl.Tax)" app/locale/en_US/Mage_Tax.csv:57:"Grand Total (Incl. Tax)","Grand Total (Incl. Tax)" app/locale/en_US/Mage_Tax.csv:58:"Grand Total (Incl.Tax)","Grand Total (Incl.Tax)" app/locale/en_US/Mage_Tax.csv:59:"Grand Total Excl. Tax","Grand Total Excl. Tax" app/locale/en_US/Mage_Tax.csv:60:"Grand Total Incl. Tax","Grand Total Incl. Tax" app/locale/en_US/Mage_Tax.csv:66:"Include Tax In Grand Total","Include Tax In Grand Total" app/locale/en_US/Mage_Rss.csv:22:"Grand Total","Grand Total" app/locale/en_US/Mage_Adminhtml.csv:366:"Grand Total","Grand Total" app/locale/en_US/Mage_Customer.csv:146:"Grand Total","Grand Total" app/locale/en_US/Mage_Sales.csv:216:"Grand Total","Grand Total" app/locale/en_US/Mage_Sales.csv:217:"Grand Total to be Charged","Grand Total to be Charged" app/locale/en_US/Mage_Sales.csv:373:"Order Grand Total","Order Grand Total" app/locale/en_US/Mage_Checkout.csv:104:"Grand Total:","Grand Total:"

or get the templates where this string is used:

 grep "__('Grand Total" app/design/ -rsn
Anton S
  • 12,750
  • 2
  • 35
  • 37
  • 1
    The text "Grand Total" isn't used in the template. If you inspect `template/tax/checkout/grandtotal.phtml` you will see `$this->getTotal()->getTitle()` instead. – clockworkgeek Nov 25 '10 at 12:01
  • then you can add this inside __($this->getTotal()->getTitle()); to get the editable string anywhere you might need it and add the appearing text to locale file I did: grep 'Grand Total' app/code/ -rsn and i see that the place where it's set has __() applied so it should be translatable/editable through locale but i did not test it out – Anton S Nov 25 '10 at 12:56
  • I wanted to sort of override the default en_US locale, but instead I overwrote the class where __ is being applied to this text. I think what you are suggesting is a better way of doing it, but we are just near launch of our website, so I chose to avoid a learning curve for that, while I have already learned overwriting Magento only for this project. – Ozair Kafray Nov 26 '10 at 07:08
5

Answer to Problem 1:

The solution is to override the

function: fetch(Mage_Sales_Model_Quote_Address $address)

in: code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php

Similarly the files Tax and Subtotal in the same folder should be edited for desired results.

The solution is a modification of a solution on the Magento community forum

Ozair Kafray
  • 13,351
  • 8
  • 59
  • 84
  • 1
    you will learn as your magento skill evolves that this is a bit overkill to solve the translation issue cause every string passed trough __() method is changeable with inline translator or through locale files in global, theme, extension scope. Doing it on the template level won't mess your upgrades and overall you have a smaller code base to look after. Look this up for your next project – Anton S Nov 26 '10 at 08:24
4

I know this thread is a little old but i recently had to solve this problem my self. The easiest solution for my needs was to rewrite the Mage_Checkout_Block_Cart_Totals class and override the renderTotals function. It ended up looking something like this:

public function renderTotals($area = null, $colspan = 1)
{
    return $this->_replaceLabels(parent::renderTotals($area, $colspan));
}


protected function _replaceLabels($html){
    $labelMap = array();
    $labelMap['Subtotal'] = "Product Total";
    $labelMap['Grand Total'] = "Order Total";
    $labelMap["Shipping & Handling"] = "Shipping";

    foreach($labelMap as $key => $value){
        $html = str_replace($key, $value,$html) ;
    }
    return $html;
}

There might be cleaner ways to do this, but this was the fastest for me.

Steven Zurek
  • 535
  • 5
  • 18
2

I'd start by flipping on template path hints. That will give you a starting point as to which template is rendering which sections of the final HTML. From there you can view the template, and see where the phtml template (or its parent block) is pulling the text from.

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
1

If your requirement is to only change the labels than you can change it from "locale". If your store locale is "United States" for example than go to "app/locale/en_US/Mage_Tax.csv", search for the text you want to change. For example: If you want to change the label "Tax" to "VAT", then search for Tax and then replace it with "VAT". IN this way you can easily change your labels. If you have your store setup for Australia,in the locale folder create a folder named "en_AU", copy Mage_Tax.csv to that folder and make the change mentioned above. This will solve your problem.

Navin Bista
  • 1,988
  • 2
  • 21
  • 37
1

Surely the quickest and safest way must be to use inline translation.

clockworkgeek
  • 37,650
  • 9
  • 89
  • 127