【问题标题】:loading magento cart block to a drop down panel将magento购物车块加载到下拉面板
【发布时间】:2012-04-13 22:07:52
【问题描述】:

谁能帮我将magento购物车块加载到下拉框中。更具体地说,模块标题或菜单应显示“我的篮子”之类的内容,并且“我的篮子”下方应显示购物车中商品数量的消息。当用户悬停菜单时,下拉框应显示 cart/sidebar.phtml 的内容。有人可以建议我如何实现这一点吗?

提前致谢。

【问题讨论】:

    标签: magento jquery css joomla1.5 shopping-cart


    【解决方案1】:

    我正在为我正在开发的网站执行此操作。不幸的是,我不得不通过一个静态块来做到这一点......但它似乎没有任何问题。这对我有用,玩一玩,看看你怎么样。

    CSS 非常简单,它们是显示和隐藏下拉菜单本身的关键。

    CSS

    // this is the panel where the cart is displayed
    DIV#cart-panel {
        width:100px; //arbitary width
        position:absolute; // need this so that it doesn't interfere with the layout
        display:none; // hides the block
        z-index:200; // makes it way it in front of other content
    }
    
    #cartBtn:hover #cart-panel { display: block; } // basically, when you hover over the cartBtn, the cart-panel displays
    

    静态块包含

    <li id="myCartBtn">
        <a href="{{store url=checkout/cart}}" rel="cart">My Cart</a>
        {{block type="checkout/cart_sidebar" template="checkout/cart/sidebar.phtml"}}
    </li>
    

    然后在我的 sidebar.phtml 中,我只需确保其中有一个 id="cart-panel" 的 div 围绕购物车本身,而不是 &lt;div class="block block-cart"&gt;

    <?php if ($this->getIsNeedToDisplaySideBar()): ?>
    <div id="cart-panel">
    ...
    </div>
    <?php endif; ?>
    

    然后,最后,我将静态块放入我需要的模板中

    【讨论】:

    • 您好,感谢您的回答,我将尝试此解决方案并告诉您进展如何。
    • 嗨 CCBlackburn,我只能在我的页面中获得购物车链接,但下拉菜单不起作用。鼠标悬停时没有显示下拉框。我完全按照你的建议做了。你知道问题出在哪里吗?
    • 我唯一能想到的是($this-&gt;getIsNeedToDisplaySideBar()) 正在返回错误...检查您是否在配置区域中启用了它。在 Admin 中转到 Configuration -> Sales -> Checkout -> Shopping Cart Sidebar 并确保“Display Shopping Cart Sidebar”设置为 Yes
    【解决方案2】:

    查看 Fatdivision AJAX 快速购物车文章。

    【讨论】:

    • 嗨,Oguz,我已经阅读了这篇文章,但遇到了一些我根本无法修复的 JS 错误。这就是我寻找其他解决方案的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-22
    相关资源
    最近更新 更多