Magento - Have different set of fields and labels for cart and checkout (order review) screens

北城余情 提交于 2019-12-02 18:15:23

问题


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

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:

and onepage checkout order review screen like

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


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/4267090/magento-have-different-set-of-fields-and-labels-for-cart-and-checkout-order-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!