0

On product pages, by default specification tab is active. How can i make the first tab i.e Description tab active by default. See https://5iallk0uwem1coeq.mojostratus.io/fabrics/zorb/zorb-original/zorb-silver.html page for reference See https://prnt.sc/vbkov0

9
  • Please add file from where that tabs come from in code. – Hamendra Sunthwal Nov 2 '20 at 6:30
  • vendor/magento/module-catalog/view/frontend/templates/product/view/details.phtml – Nafsss Nov 2 '20 at 6:38
  • @Nafsss, You can simply use jQuery – Pawan Nov 2 '20 at 7:52
  • I tried, but it did not work perfectly – Nafsss Nov 2 '20 at 7:53
  • jQuery('.product.data.items .data.item.title').removeClass('active'); jQuery('#tab-label-additional').addClass('active'); jQuery('.product.data.items .data.item.content').css('display','none'); jQuery('#additional').css('display','block'); – Pawan Nov 2 '20 at 7:54
1

Add this to your phtml file.

<script>
  require(
      [
          'jquery',
      ],
      function($) {
        $("a#tab-label-description-title").trigger('click');
      }
  );
</script>
2
  • Did not work...... – Nafsss Nov 3 '20 at 5:14
  • @Nafsss use setTimeout(function(){ alert("Hello"); }, 3000); this function – Msquare Nov 3 '20 at 6:11
0

If you want to show description tab active on product pages,change code line in catalog_product_view.xml file

Here by default, "Details" tab is active, if you want to active "More Information" by default then,just change sort_order of "Details" tab to 20 from 10 and "More Information" tab to 10 from 20.Similarly by changing sort_order you can achieve your requirement.

<block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description" template="Magento_Catalog::product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getDescription</argument>
<argument name="at_code" xsi:type="string">description</argument>
<argument name="css_class" xsi:type="string">description</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Details</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
 </block>
 <block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
</block>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.