Terry - 专注外贸B2C

GitHub地址:https://github.com/fancyecommerce

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

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/

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/terry_water/article/details/6157704
想对作者说点什么? 我来说一句

PHP/MySQL 购物车程序

zgqtxwd zgqtxwd

2008-05-01 03:46:00

阅读数:298

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭