I have a dropdown product attribute named: shine_fine . i want to hide stock status from product page when any option from shine_fine attribute is selected. i don't want to disable Magento stock status i just want to hide it.


this is my shine_fine attribute code in view.phtml:

<?php if($_shineFine = $_product->getAttributeText('shine_fine')): ?>
    <img src="/media/atticons/<?php echo $_shineFine ?>.png">
<?php endif; ?>
  • Are you looking for more of a javascript solution?
    – Egregory
    Mar 3 '15 at 20:25
  • @Egregory could it be done with java script? or i need to make an extension?
    – Moh3n
    Mar 3 '15 at 20:58
  • You can probably do it pretty simply with javascript. Since it's client side interaction you are trying to detect you would have to use javascript.
    – Egregory
    Mar 3 '15 at 22:16

Open the file app/design/frontend/package/default/template/catalog/product/view/type/default.phtml (or) (or copy from app/design/base/default/template)

Add logic around the output.

<?php if ($this->displayProductStockStatus() && !$_product->getAttributeText('shine_fine')): ?>
    <?php if ($_product->isAvailable()): ?>
        <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
    <?php else: ?>
        <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
    <?php endif; ?>
<?php endif; ?>

So, if your attribute is set, no output will be shown.

(Added another answer after your last edits and additions)

  • there is not template/catalog/product/type/default.phtml in any of my packages!
    – Moh3n
    Mar 4 '15 at 9:13
  • Sorry, forgot about the /view - edit my answer
    – Jeroen
    Mar 4 '15 at 9:17
  • its working like a charm
    – Moh3n
    Mar 4 '15 at 9:24

If you use the latest template and have jquery.

Add this after your custom attribute.

  • im new in magento and also jQuery.i updated my question. i will thankful if you tell me where to put this code in my view.phtml
    – Moh3n
    Mar 4 '15 at 5:30

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.