隐藏顶部菜单上的购物车当它为空时

时间:2015-06-13 03:25:45

标签: php xml magento magento-1.8

有没有办法在顶层菜单上显示空白时隐藏购物车?我相信它在Links.php文件上,但我不知道要添加什么代码。此外,“Links.php”是一个Core文件,我正在考虑在Local上为它创建一个新模块。会有用吗?感谢。

2 个答案:

答案 0 :(得分:0)

隐藏购物车边栏:

1. Open: app/design/frontend/default/<your template>/template/checkout/cart/sidebar.phtml

2. Go to line 32 Look for

<div class="box base-mini mini-cart">

3. Add these lines right before that opening div tag

<?php $_cartQty = $this->getSummaryCount() ?>
<?php if ($_cartQty >0): ?>

4.Add this line to the bottom of the file
  

购物车只会显示用户是否将商品添加到购物车中。

     

或者使用这些插件......它是一个免费的插件,可以隐藏它   空..   Xogenics Hide Cart for Magneto

隐藏在标题菜单中使用此

  

从标题菜单中删除我的购物车和结帐链接。代码为   这些链接位于checkout.xml文件中:

In Magento, on your ecommerce site may be you do not want to show MyCart or Checkout links.Follow the steps below to remove the link.

1. Copy the file checkout.xml from app/design/frontend/base/default/layout to app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout or app/design/frontend/default/YOUR_THEME/layout

2. Edit the checkout.xml copied to the app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout folder or app/design/frontend/default/YOUR_THEME/layout folder

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

4. Comment the following Lines

4.1 Comment the following Line to Remove My Cart Link from header
<!--<action method="addCartLink"></action>-->

4.2 Comment the following Line to Remove Checkout Link from header
<!--<action method="addCheckoutLink"></action>-->

5. Refresh the Magento Cache and Website Page to see the changes

答案 1 :(得分:0)

$(document).ready(function(){
     $(".top-car").hide(); 
 });

首先检查购物车中的数量是否有以下内容:

$qty = $this->helper('checkout/cart')->getSummaryCount()

希望这有助于你