2012-09-06 54 views
6

的分裂選項在默認佈局的選項,並添加到購物車按鈕被Magento的 - container1和container2的

<?php echo $this->getChildChildHtml('container1', '', true, true) ?> 

叫我想從添加到購物車拆分配置選項和數量字段來顯示他們在我的佈局中的不同位置。任何想法或準備使用變通辦法?

+0

你得到了什麼?我也需要「手動添加到購物車」鏈接。 – KarSho

+0

由於這個老話題得到了很多觀點,我想分享我的解決方法解決這個問題。 我尋找'container1'裏面的內容,並直接在view-Template中渲染它,或者用'getChildHtml'爲產品選項調用內容,這將是'$ this-> getChildHtml('product_options_wrapper')'。 – npostulart

回答

0

當你的最終解決將取決於在哪裏這些塊需要移動/插入你的佈局,你絕對可以拆分「加入購物車」 product.info.options.wrapper.bottom出從配置選項product.info.container1product.info.container2這樣的:

<catalog_product_view> 
    <reference name="product.info.container1"> 
     <action method="unsetChild"><name>product.info.options.wrapper.bottom</name></action> 
    </reference> 
    <reference name="product.info.container2"> 
     <action method="unsetChild"><name>product.info.options.wrapper.bottom</name></action> 
    </reference> 
</catalog_product_view> 

到然後分別顯示「加入購物車」按鈕,最簡單的辦法是註釋掉條件在catalog/product/view.phtml允許product.info.addtocart塊中顯示的產品是否有選擇與否:

<?php if (!$this->hasOptions()): // Remove this condition ?> 
    <div class="add-to-box"> 
     <?php if($_product->isSaleable()): ?> 
      <?php echo $this->getChildHtml('addtocart') ?> 

      ... 

     <?php endif; ?> 
    </div> 

    ... 

<?php endif; ?> 

希望能幫助你理解這些塊的結構。其他資源可能會有所幫助:

1

您可以分割很容易的(但我花了很多時間去尋找吧:)) - 如果你看看app/code/core/Mage/Core/Block/Abstract.php到PHPDoc的public function getChildChildHtml,你會看到第二個參數確定了子塊的名稱。所以,你可以先調用價塊之前渲染

<?php echo $this->getChildChildHtml('container1', 'product.info.options.wrapper', true, true) ?> 

和價格呈現塊之後,調用

<?php echo $this->getChildChildHtml('container1', 'product.info.options.wrapper.bottom', true, true) ?>