Show quantity, total price and shipping price in my header.phtml?

原创 2011年01月21日 21:10:00

Show quantity, total price and shipping price in my header.phtml?
2009-10-25 17:21

在magento论坛上的讨论,其中一个人写的:

Weehuu, finally I figured something out…

How do I show the quantity of a cart in my header?

Add the following code to app/design/frontend/[theme]/default/template/page/html/header.phtml:

 

<? if(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() > 0{ ?>
<?
=__(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty())?> 
<? } 
else { ?>

<? } ?>

How do I show the total price of a cart in my header?

I have only found a solution for the subtotal, and to show this, you need to add the following to app/design/frontend/[theme]/default/template/page/html/header.phtml (or wherever you need it):

 

<? if(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal() > 0{ ?>
<?
=__(number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(),2))?> 
<? } 
else { ?>

<? } ?>

How do I show the total shipping price in my header?

Still trying to figure this out…

 

 

 

另外一个人写的:

I search hi and low before I found a solution and then had to do a lot of tweeking before it worked but here is what I did:

1.  Add an action method to get the subtotal in the checkout.xml file (found in app/design/frontend/default/[YOUR THEME]/layout)

Look for 
<reference name="top.links"> 
<block type="checkout/links" name="checkout_cart_link"> 
<action method="addCartLink"></action> 
<action method="addCheckoutLink"></action> 
</block>

And change to

<reference name="top.links"> 
<block type="checkout/links" name="checkout_cart_link"> 
<action method="addCartLink"></action> 
<action method="ADDSUBTOTALCODE"></action> 
<action method="addCheckoutLink"></action> 
</block>

Notice all I did was to add 
<action method="ADDSUBTOTALCODE"></action>

2.  Open links.php found in app/code/core/Mage/Checkout/Block) and Add a function to get the cart subtotal

public function ADDSUBTOTALCODE () 

if ($parentBlock = $this->getParentBlock()) 

$amount = __(number_format(Mage::getSingleton(’checkout/session’)->getQuote()->getSubtotal(),2)); 
$text = __(’Amount $%s’, $amount); 
$parentBlock->addLink($text, ‘checkout/cart’, $text, true, array(), 50,null,’class="top-link-cart"’); 


return $this; 

}

3.  Save files and upload them back to the server.

**Please ntoe to first make a backup of all the files being updated before changes are made as core files are being changed**

 

还有另外一篇文章:

http://www.magentocommerce.com/boards/viewthread/32320/

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

PAT 1090. Highest Price in Supply Chain (25)

1090. Highest Price in Supply Chain (25) 时间限制 200 ms 内存限制 65536 kB 代码...

PAT A1090 Highest Price in supply chain

//PAT A1090 ac #include #include #include using namespace std; const int maxn=100010;//注意数据大小 vect...

PAT (Advanced Level) Practise 1106 Lowest Price in Supply Chain (25)

1106. Lowest Price in Supply Chain (25) 时间限制 200 ms 内存限制 65536 kB 代码长...

1106. Lowest Price in Supply Chain (25) 树的遍历,DFS

Lowest Price in Supply Chain (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 ...

PAT A1090. Highest Price in Supply Chain (25)

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo...
  • jolivan
  • jolivan
  • 2017年02月24日 20:32
  • 60
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Show quantity, total price and shipping price in my header.phtml?
举报原因:
原因补充:

(最多只允许输入30个字)