3

I added custom tabs to product detail page. Below is my code:

<block type="catalog/product_view_description" name="product.new.tab" as="new.tab" template="catalog/product/view/mynewcustomtab.phtml">
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle" translate="value"><value>Stock Details</value></action>
</block>

I have added this code into catalog.xml

My problem is that

  1. I want to add condition that it will show only if user type is wholeseller
  2. I want to show if only for configurable products?
3

There are several ways, like adding a simple if else statement retrieving the users customer group but Atwix has a nice post about adding customer group layout handles which I would recommend to follow after which, in your local.xml you can add

<customer_group_wholesale>
   <reference name="product.info">
      <block type="catalog/product_view_description" name="product.new.tab" as="new.tab" template="catalog/product/view/mynewcustomtab.phtml">
         <action method="addToParentGroup"><group>detailed_info</group></action>
         <action method="setTitle" translate="value"><value>Stock Details</value></action>
      </block>
   </reference>
</customer_group_wholesale>
1
  • Very good intro into adding custom layout handles but how could you link this and product type :) – David Manners May 1 '15 at 17:10
1

So to show this block for only configurable products you can use the product type based layout handle PRODUCT_TYPE_configurable. Now your code should look like the following.

<PRODUCT_TYPE_configurable>
    <reference name="product.info">
        <block type="catalog/product_view_description" name="product.new.tab" as="new.tab" template="catalog/product/view/mynewcustomtab.phtml">
            <action method="addToParentGroup"><group>detailed_info</group></action>
            <action method="setTitle" translate="value"><value>Stock Details</value></action>
        </block>
    </reference>
</PRODUCT_TYPE_configurable>

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.