0

I am developing a module where I need to set discounted price for a product if applicable. Admin will set a discount percent from backedn for a product and based on that the product price will be calculated.

For ex:

Product Price = 299
Discount Percent = 20%
Discounted Price = 239.20

So the price for that product will be 239.20. I have displayed the discounted price successfully on listing page and the file changes is

catalog/product/list.phtml

But now I also need to change the price on product detail page. The file being used to display the price is

catalog/product/price.phtml

I do not want to change the .phtml file as it has number of conditions for price display.

enter image description here

What is the best method to set the discounted price on product detail page ?

I hope my question is clear.

Please Help.

Thanks

  • for Special Price you can use Magento Special price Functionality – Keyul Shah Jul 22 '14 at 4:28
  • Edited my question – Jordan Jul 22 '14 at 4:48
  • @Jordan Why are you not using catalog price rule ? – Mufaddal Jul 22 '14 at 6:33
  • For that if admin changes the discount percent, I again have to make changes in price rules. Also I have to specify SKU's everytime. Currently admin is selecting the products from my custom module – Jordan Jul 22 '14 at 6:37
  • How are you getting the price on the product listing page? – pspahn Jul 22 '14 at 7:35
1

Magento has the ability to display the special price when it is set on a product:

enter image description here

This is styled in the Magento frontend with the markup

<p class="special-price">
    <span class="price-label">Special Price</span>
    <span class="price" id="product-price-423">$224.00</span>
</p>

So using the following CSS should allow you to style it how you see fit:

.special-price .price { 
   /* your rules here */
}

enter image description here

  • Yes I know the special price settings, but I have a custom module that applies discount on a product and that discounted price will be shown in the special price HTML format as you have shown above. – Jordan Jul 22 '14 at 5:21
  • Please clarify exactly what you are expecting from us so we can give you proper guidance. – philwinkle Jul 22 '14 at 5:22
  • If a product falls under a deal, it will have a discounted price which will be shown on listing as well as detail page. I am not sure how to display it on details page as it has number of setPrice() conditions. Discount price is not special price. – Jordan Jul 22 '14 at 5:24
  • Have you created a new attribute with a type of price? If so you can display this just about anywhere in the product templates with $this->getProduct()->getMySpecialPrice() or something akin to that – philwinkle Jul 22 '14 at 5:26
  • No, admin will give discount percent on a deal and based on that I am calculating the price on frontend. This does not includes any attribute creation but simply specifying discount percent from backend. – Jordan Jul 22 '14 at 5:28

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.