I have a category of products that can't be bought online directly but that I want to give the functionality of going to a distributors page.
For that, I need to retrieve the category id of the current product and if it's equal to 13 display a different content for the add to cart button.
So far, the code that I have is:
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php $categoryId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId(); ?>
<?php if ($categoryId == 13) {?>
<div class="add-to-cart v-centered-content">
<button type="button" title="<?php echo $this->__('Find your nearest retailer') ?>" id="product-addtocart-button" class="button btn-cart v-center" onclick="setLocation('<?php echo $this->getUrl('distributors') ?>')"><span><span><?php echo $this->__('Find your nearest retailer') ?></span></span></button>
</div>
<?php }
elseif ($_product->isSaleable()) { ?>
<div class="add-to-cart v-centered-content">
<button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart v-center" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<?php if(!$_product->isGrouped()){ ?>
<div class="qty-wrapper v-center">
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
</div>
<?php } ?>
</div>
<div class="paypal-wrapper"><?php echo $this->getChildHtml('', true, true) ?></div>
<?php } ?>
Could you guys help me with getting this to work?
Thanks.