Magento - split options of container1 and container2
Asked Answered
T

2

6

In the default layout the options and add-to-cart-button are called by

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

I would like to split the configurable options from the add-to-cart and quantity field to show them on a different position in my layout. Any ideas or ready to use workarounds?

Tother answered 6/9, 2012 at 9:20 Comment(2)
Are you got? i too need 'add-to-cart' link for manual.Moxa
As this old topic gets a lot of views I would like to share my workaround for this problem. I looked out for the content inside container1 and rendered it directly in the view-Template or call the content with getChildHtml for the product options this would be $this->getChildHtml('product_options_wrapper').Tother
R
2

You can split it very easy (but I spent a lot of time to find it :) ) - if you look to the app/code/core/Mage/Core/Block/Abstract.php to PHPDoc of public function getChildChildHtml, you will see that the second parameter determined child block name. So, you can call first before the price block render

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

and after price block rendered, call

<?php echo $this->getChildChildHtml('container1', 'product.info.options.wrapper.bottom', true, true) ?>
Recriminate answered 10/1, 2017 at 16:2 Comment(0)
C
0

While your final solution will depend on where these blocks need to be moved/inserted in your layout, you can definitely split the “Add to Cart” product.info.options.wrapper.bottom out from configurable options product.info.container1 or product.info.container2 like this:

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

The easiest way to then show the “Add to Cart” button separately is to comment out the conditional in catalog/product/view.phtml which allows the product.info.addtocart block to be shown whether the product has options or not:

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

Hopefully that helps you understand the structure of these blocks. Additional resources that may be helpful:

Chev answered 12/2, 2015 at 23:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.