0
votes

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

alt text

My Problem is to show the Tax and Grand Total Including tax fields to appear in the cart, because the tax is calculated once we know the shipping address. So, we want to show it only in the Checkout Screen under Order Review. However, when overriding the template/ file mentioned above, also modifies the Order Review field in checkout, so that it looks like this:

alt text

and onepage checkout order review screen like

alt text

which means that these fields are being controlled from one set of file(s). However, I want these two (totals box in cart AND order review in checkout) to be different.

By turning on the template path hints I know that the child templates for each of subtotal, tax, total... are being called from:

Cart: /checkout/cart.phtml

Checkout (One page): /checkout/onepage/review/info.phtml

Both of these have this common line, which I believe does the trick

$this->getChildHtml('totals')

Can someone help me in knowing how does getChildHtml looks up the 'totals' file. I am confused because there is a totals.phtml in checkout/onepage/review folder, while both of them are actually using template files in /tax/checkout

I am using Magento 1.4.1.1 and background to this question is a previous question

2

2 Answers

1
votes

From your previous question you already know the output comes from the file template/tax/checkout/grandtotal.phtml. It's decision to show a 1 or 3 totals lines is based on this snippet:

<?php if ($this->includeTax() && $this->getTotalExclTax()>=0):?>

I would suggest changing it to...

<?php if ($this->includeTax() && $this->getTotalExclTax()!=$this->getTotal()):?>

Here, when the address is unknown and tax is zero, the two grand totals are equal and so only one is shown.

This is doubly beneficial, when an address is supplied by the "Shipping and Tax Estimate" form then the cart can still go back to the 3-line output automatically which is smooth.

1
votes

You have several options

  1. You can sniff the location of the user with GeoIp and set at least the country in quote billing address so you'll get the tax estimates to display. For example to get the UK estimates you can do (if quote exists) <?php $this->getQuote()->getBillingAddress()->setCountryId('UK');?> or <?php $this->getQuote()->getShippingAddress()->setCountryId('UK');?>
  2. You can change the template file to be different in cart and in checkout by modifying the checkout.xml layout file and make your conditions in separate files