2015-10-23 83 views
1

你好,我刚刚登录问这个问题。我尝试用该论坛给出的答案来解决这个问题,但是一切都不行。 我只想将购物车中的商品添加到magento kontactform中的文本字段中。我使用form.phtml在phtml Contactform(Magento)中显示购物车物品

我试图显示与侧边栏车:

<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> 

,但我得到这个错误:

Fatal error: Call to a member function getProduct() on a non-object in /www/htdocs/xxxxx/magento/app/design/frontend/base/default/template/checkout/cart/sidebar/default.phtml on line 29

第29行是:

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

所以有人可以帮助我,并对我的残酷英语感到抱歉:-)

+0

替换使用此代码 getLayout() - > createBlock('结帐/ cart_sidebar ') - > setTemplate(' 结帐/购物车/ sidebar.phtml') - > toHtml(); ?> –

+0

如果条件“<?php if($ this-> getIsNeedToDisplaySideBar()):>” –

+0

您还需要评论吗?嗨,谢谢你,但它仍然没有成功,我是php newbe也许我做了一些基本上错误的事情。我添加代码 'code' <?php if($ this-> getIsNeedToDisplaySideBar()):?> <?php echo $ this-> getLayout() - > createBlock('checkout/cart_sidebar') - > setTemplate '结帐/购物车/ sidebar.phtml') - > toHtml(); ?> <?php endif; ?> '代码' – bikefactory

回答

0

其实,您正在使用核心/模板块,这就是为什么你会收到错误,所以请使用结帐/ 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(); ?> 

感谢

相关问题