繁体   English   中英

在phtml Contactform(Magento)中显示购物车项目

[英]Display Shopping Cart items in phtml Contactform (Magento)

您好,我刚刚登录问这个问题。 我尝试在该论坛中使用给定的答案来解决该问题,但无法正常进行。 我只想将购物车中的物品包括在magento kontactform的文本字段中。 我使用form.phtml

我尝试用以下方式显示侧边栏购物车:

  <label for="comment">Artikel</label>
            <div class="input-box">
                <textarea name="comment" id="comment" title="Artikel" class="required-entry input-text" cols="5" rows="3">

                <?php echo $this->getLayout()->createBlock('core/template')->setTemplate('checkout/cart/sidebar/default.phtml')->toHtml(); ?>
                </textarea>
            </div>
        </li>
        <li class="wide">
            <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
            <div class="input-box">
                <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>

但我得到这个错误:

致命错误 :在第29行的/www/htdocs/xxxxx/magento/app/design/frontend/base/default/template/checkout/cart/sidebar/default.phtml中的非对象上调用成员函数getProduct()

第29行是:

$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();

所以有人可以帮助我,对不起我的英语:-)

实际上,您正在使用core / template块,这就是为什么会出错,因此请使用checkout / cart_sidebar块。 请用以下代码替换您的代码。

您的密码

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('checkout/cart/sidebar/default.phtml')->toHtml(); ?>

用。。。来代替

<?php echo $this->getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('checkout/cart/minicart/items.phtml')->toHtml(); ?>

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM