2

I am trying to use a custom Yes/No attribute to show/hide an element within the Price.phtml file but whenever I add the condition I keep getting this error and I can't understand why since I had it working previously.

Here is what I have added from line 359 of Price.phtml

    <?php if ($_taxHelper->displayBothPrices()): ?>
        <p class="special-price">
            <span class="price-label"><?php echo $_specialPriceStoreLabel ?></span>
            <span class="price-excluding-tax">
                <span class="label"><?php echo $this->helper('tax')->__('Excl. Tax:') ?></span>
                <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
                </span>
            </span>
            <span class="price-including-tax">
                <span class="label"><?php echo $this->helper('tax')->__('Incl. Tax:') ?></span>
                <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?>
                </span>
            </span>
        </p>
    <?php else: ?>
        <?php if ($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes"): ?>
        <span class="del" style="display: none;"><?php echo $this->__('RRP') ?> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?><?php $regularprice =  $_regularPrice; ?></span>
        <?php         $price_diff = $regularprice-$finalPrice;
        $discountPercent = ($price_diff/$regularprice)*100;
        $discountPercent = ceil($discountPercent); ?>
        <span class="discount" style="display: none;">(-<?php echo $discountPercent; ?>%)</span>
            <?php else: ?>
            <span class="del"><?php echo $this->__('RRP') ?> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?><?php $regularprice =  $_regularPrice; ?></span>
            <?php         $price_diff = $regularprice-$finalPrice;
            $discountPercent = ($price_diff/$regularprice)*100;
            $discountPercent = ceil($discountPercent); ?>
            <span class="discount">(-<?php echo $discountPercent; ?>%)</span>
        <?php endif; ?>
    <?php endif; ?>
<?php endif; ?>

Basically what I would like to achieve is by adding a new attribute and adding it to the price group I can set whether to display special price on the frontend or not for certain products.

I keep getting this error:

function getSource() on a non-object in /*****/*****/public_html/app/code/core/Mage/Catalog/Model/Product.php on line 1390

Can anyone see what I have done wrong?

  • could you post your complete error? where is that actually fired? file/line? – Tobias Jan 17 '14 at 12:22
  • @TobiasZander Thanks for the reply, please see my edits. – user1704524 Jan 17 '14 at 13:06
3

This line is incorrect wich causes the problem:

if($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes")

Use like this:

if($_product->getHideSpecialPrice())

or

if($_product->getData('hide_special_price'))

And your attribute hide_special_price should be "Used in Product Listing" and "Visible on Product View Page on Front-end" (see attribute edit page).

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.