0

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; ?>
2

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; ?>

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.