- Find and open the tabs.phtml file. you can find it here:
- app/design/frontend/[YOUR PACKAGE]/[YOUR
THEME]/template/catalog/product/view/tabs.phtml
Now get the total number of upsell products for the current product
$product_id = Mage::registry("current_product")->getId();
$_product = $object->load($product_id);
$upsell_count = count($_product->getUpSellProductIds());
NOW FIND THIS LINES OF CODE
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php if($this->getChildHtml($_tab['alias'])): ?>
<li id="tab_<?php echo $_tab['alias'] ?>" class="<?php echo ($i==0)?' active first':''?>"><a href="#"><?php echo $_tab['title']?></a></li>
<?php endif; ?>
<?php endforeach; ?>
AND REPLACE IT WITH THIS CODE
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php if($this->getChildHtml($_tab['alias'])):
if($_tab['alias'] == 'youe_newly_created_tab_id' && ($upsell_count > 0))
{ ?>
<li id="tab_<?php echo $_tab['alias'] ?>" class="<?php echo ($i==0)?' active first':''?>"><a href="#"><?php echo $_tab['title']?></a></li>
<?php }
elseif($_tab['alias'] == 'youe_newly_created_tab_id' && ($upsell_count == 0))
{
echo "";
}
else
{ ?>
<li id="tab_<?php echo $_tab['alias'] ?>" class="<?php echo ($i==0)?' active first':''?>"><a href="#"><?php echo $_tab['title']?></a></li>
<?php }
$i++; ?>
<?php endif; ?>
<?php endforeach; ?>
AFTER REPLACING CODE IT WILL HIDE YOUR TAB IF UPSELL PRODUCTS IS NOT THERE
AND FOR TAB CONTENT (BELOW TAB TITLE) APPLY SAME CODITIONS WHERE TAB CONTENT ARE CREATED
NOTE: i know this is not a proper solution but it solved my issue