2015-10-23 80 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(); ?> 

感謝

相關問題