How to Hide Price When Price Equals 0

price

I need to show a message such as "call us" for certain products.

I cannot find any extension that works nicely with grouped products (which I use) – so making my own hack seems to be the only solution.

I saw this thread: Hiding Price if 0

and using that, we get the code:

<?php if ($_product->getFinalPrice() == 0) : ?>
    <h2>Call  To Order</h2>
<?php else: ?> 
    <?php echo $this->getPriceHtml($_product); ?>
<?php endif; ?>

But maybe I don't put it in correctly, but it shows the call to order message for me + prices for all items in the list. Here is my code:

<td class="a-right">
                <?php if ($this->getCanShowProductPrice($_item)): ?>
                <?php echo $this->getPriceHtml($_item, true) ?>

                <?php //new hide price function ?>
                <?php if ($_product->getFinalPrice() == 0) : ?>
                <h2>Call  To Order</h2>
                <?php else: ?> 
                <?php echo $this->getPriceHtml($_product); ?>
                <?php endif; ?>
                <?php //end of new hide price function ?>


                <?php echo $this->getTierPriceHtml($_item) ?>
                <?php endif; ?>
            </td>

Any tips on how to get that working? Thanks!

Best Answer

Try

<td class="a-right">
            <?php if ($this->getCanShowProductPrice($_item)): ?>


            <?php //new hide price function ?>
            <?php if ($_item->getFinalPrice() == 0) : ?>
            <h2>Call  To Order</h2>
            <?php else: ?> 
            <?php echo $this->getPriceHtml($_item); ?>
            <?php endif; ?>
            <?php //end of new hide price function ?>


            <?php echo $this->getTierPriceHtml($_item) ?>
            <?php endif; ?>
        </td>

and if that dont work, change $_item for $_product.

Related Topic