1

enter image description hereSo I am trying to create a function that states that if the product is new in stock then display price, or if the product is not new but reconditioned then I want it to display the reconditioned price, and lastly if there is none of the product in stock to display a "call for pricing" message. I am looking to do this in the price.phtml file and would like to know how to do this, I have an idea of what I want to do but I'm not entirely sure how to execute this code, please help! The image added is essentially what I would like to be done with code.

1 Answer 1

1

Instead of rewriting the price.phtml I would use the catalog_product_get_final_price event that is triggered from Mage_Catalog_Model_Product_Type_Price::getFinalPrice

In your observeryou can set the final_price data of a product

$observer->getProduct()->setData('final_price', $ yourCustomPrice);

This will overwrite other previously set prices

12
  • I'm not sure I fully understand, so if not in price.phtml, then where?
    – Mhernandez
    Commented Nov 5, 2015 at 16:27
  • As I mentioned I would use an observer. you can add one by creating your own module and defining the observer Commented Nov 5, 2015 at 16:27
  • I'm not sure, I have created a module for custom php before, but this should be simpler, could it not? I'm not intending to write up an entire new price.phtml file but more so adding a few lines of code to it. I believe I have price information for New and Reconditioned products in Magento so I was hoping to just call to that with a function for the products in the Price.phtml file.
    – Mhernandez
    Commented Nov 5, 2015 at 16:38
  • @Mhernandez I've done this several times before and found it to be the easiest and cleanest way to do this. Works consistently and is easily scalable Commented Nov 5, 2015 at 18:19
  • ok, so looking at the image I've now added, could I do that for what is detailed in the image? also you said I would do this by creating a module, so just to be perfectly clear the code you gave me would go where? In a custom php file after I've created all module.xml file as well as the config file? or would it go somewhere else?
    – Mhernandez
    Commented Nov 5, 2015 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.