PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] Where are defined options_container template in Magento 2

 August 23, 2022     magento, magento2     No comments   

Issue

I have this code in my form.phtml

/**
* Product view template
*
* @var $block \Magento\Catalog\Block\Product\View
*/
<?php if ($_product->isSaleable() && $block->hasOptions() && $block->getOptionsContainer() == 'container2'): ?>
    <?php echo $block->getChildChildHtml('options_container'); ?>
<?php endif;?>

And here is the layout catalog_product_view

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="MM_Catalog::css/magnific-popup.css"/>
    </head>
    <body>
        <referenceContainer name="content">
            <referenceBlock name="product.info">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">MM_Catalog::product/view/form.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

This works, but I need to add more fields into the printed fieldset. But I don't know where and how I am supposed to specify these fields that are printed into the fieldset.

Thanks for your help


Solution

Check the default layout file catalog_product_view.xml you will find that

"options_container" contains another secondary block inside it named as "product_options_wrapper" which contains the following template

Magento_Catalog::product/view/options/wrapper.phtml

You can add more fields here by overriding it in your custom module .

"product_options_wrapper" contains another secondary block "product_options" which is responsible for option's rendering.

So if you want to add more fields according to options you can find corresponding templates for each options over there like,for Text input

Magento_Catalog::product/view/options/type/text.phtml

You can add fields in this templates by overriding it in your custom module.



Answered By - Rahul Barot
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing