Magento - split versions of container1 and container2

In the default layout, the parameters and the add-to-cart button are called

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

I would like to separate the custom parameters from the add-to-cart field and the number to show them elsewhere in my layout. Any ideas or ready-to-use workarounds?

+6
source share
2 answers

You can easily break it down (but I took a lot of time to find it :)) - if you look at the application / code / kernel /Mage/Core/Block/Abstract.php in the PHPDoc public function getChildChildHtml , you will see that the second parameter defined the name of the child block. So you can call first before rendering the price block

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

and after displaying the price block, call

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

While your final decision will depend on where these blocks are to be moved / inserted into your layout, you can split the "Add to Cart" product.info.options.wrapper.bottom from the custom parameters product.info.container1 or product.info.container2 as follows:

 <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 show the Add to Cart button separately is to comment out the conditional expression in catalog/product/view.phtml , which allows you to display the product.info.addtocart block whether the product has parameters 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; ?> 

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

0
source

Source: https://habr.com/ru/post/924716/


All Articles