Question

I want to add some class to the <p class="old-price">, when the product got a special price.

NOTE: I only want to add this, if the product got a special price, not a catalog price rule.

How can I achieve that inside the price.phtml block ?

The code I want to edit is:

<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
            <p class="old-price" >
                <span class="price-label"><?php echo $this->__('Regular Price:') ?></span>
                <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->formatPrice($_regularPrice + $_originalWeeeTaxAmount, false) ?>
                </span>
            </p>
<?php endif; ?>
Was it helpful?

Solution

The Mage_Catalog_Model_Product class has the method getSpecialPrice(). If the product has a special price set, the method will return the special price.

Knowing that Magento uses the lowest active price to sell the product at, you can do something like this:

<?php //In price.phtml ?>
<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
    <p class="old-price <?php echo $_product->getSpecialPrice() == $_product->getFinalPrice() ? 'special-price-class' : ''; ?>" >
        <span class="price-label"><?php echo $this->__('Regular Price:') ?></span>
        <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
            <?php echo $_coreHelper->formatPrice($_regularPrice + $_originalWeeeTaxAmount, false) ?>
        </span>
    </p>
<?php endif; ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top