【发布时间】:2015-10-23 10:20:50
【问题描述】:
您好,我刚登录是为了问这个问题。我尝试使用该论坛中给定的答案来解决该问题,但有些东西不起作用。
我只想将购物车中的商品添加到 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>
但我收到此错误:
致命错误:在 a 上调用成员函数 getProduct() 非对象在 /www/htdocs/xxxxx/magento/app/design/frontend/base/default/template/checkout/cart/sidebar/default.phtml 上线 29
第 29 行是:
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
所以有人可以帮助我,对不起我残酷的英语:-)
【问题讨论】:
-
使用这个代码 getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('checkout/cart/sidebar.phtml')->toHtml( ); ?>
-
另外你需要注释 if condition "getIsNeedToDisplaySideBar()):?>"
-
嗨,谢谢你,但它仍然不起作用,我是一个 php 新手,所以也许我做错了什么。我添加代码
codegetIsNeedToDisplaySideBar()):?> getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('checkout /cart/sidebar.phtml')->toHtml(); ?>code -
但我总是得到一个空白框。我尝试使用和不使用“标签