【问题标题】:Magento:Custom dropdown cart - How to get "my cart" link?Magento:自定义下拉购物车 - 如何获取“我的购物车”链接?
【发布时间】:2012-02-10 20:54:55
【问题描述】:

我正在开发基于 Magento 侧边栏购物车功能的下拉购物车。感谢一个教程,我在编辑 checkout.xml 和 page.xml 文件时得到了这个工作,但是我想通过编辑我的 local.xml 文件来做真正的 Magento 方式。这是我的代码:

header.phtml

div class="top-cart">
<?php echo $this->getChildHtml('topCart') ?>
<div class="top-cart-menu">
<?php echo $this->getChildHtml('topCartBlock') ?>
</div>
</div> 

local.xml

  <block type="checkout/cart_sidebar" name="cart_sidebar" as="topCartBlock" template="checkout/cart/sidebar.phtml" before="-" >
    <action method="addItemRender">
      <type>simple</type>
      <block>checkout/cart_item_renderer</block>
      <template>checkout/cart/sidebar/default.phtml</template>
    </action>
   <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
      <label>Shopping Cart Sidebar Extra Actions</label>
    </block>
  </block>

到目前为止,它正在工作,我的标题中显示了侧边栏迷你购物车。但为了实现鼠标悬停,我需要购物车链接。当我将上面的代码和以下代码放在 page.xml 中时,它正在工作,但当我将它添加到我的 local.xml 中时,链接没有显示出来。

<reference name="top.cart">
  <action method="addLink" translate="label title">
    <label>Your Cart</label>
    <url>checkout/cart</url>
    <title>Your cart</title>
    <position>1</position>
    <li/>
    <a>id="top-link-cart"</a>
  </action>
</reference>

如何修改此代码才能获得“我的购物车”链接?

【问题讨论】:

  • 如果您找到有效的解决方案,您可以创建自己的答案并接受它。
  • 一旦您接受了答案(通过单击对勾),就无需用 [solved] 标记标题。

标签: php xml magento shopping-cart cart


【解决方案1】:

我通过用

替换最后的代码部分来让它工作
<block type="page/template_links" name="topCart" as="topCart"> 
  <block type="checkout/links" name="cart_link"> 
    <action method="addCartLink">
    </action>
  </block>
</block> 

这为我们提供了购物车的链接,我将用作鼠标悬停链接

【讨论】:

  • 欢迎来到 Stackoverflow。您可以删除您的相关评论并剥离(编辑)答案中的参考 beautify it :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-19
  • 1970-01-01
  • 2015-07-06
  • 1970-01-01
相关资源
最近更新 更多