I am beginner to magento and want to disable "Add to cart" button when special price to date is ended, is there a way to do that? thanks.


Yes,you can do,but need write some code at yours template file(phtml files).

For your requirement,you need to check current date is between the special price end date & start date.

I assume that $_product is a product object(Object of Mage_Catalog_Product) of a product. Check the current date with special price to date(special_date).

Then using js script buttonObject.disabled = true; disabling the button

$specialprice = $_product->getSpecialPrice();
$specialPriceFromDate = $_product->getSpecialFromDate();
$specialPriceToDate = $_product->getSpecialToDate();
$dateToday = date('Y-m-d');
// check current product special price end end greater then today
if ($_product->getPrice() > $_product->getFinalPrice() && $dateToday<=$specialPriceToDate $dateToday => $specialPriceFromDate):
// run js code
  • Thank you Amit for your help, but there is many phtml file in my template directory. I add this code to 'template\catalog\product\list.phtml' inside php markup and nothing happened. when use the code above my php editor hint the line begins by 'if' and between $specialPriceToDate and $dateToday may be has '&&'?
    – Aqronis
    Nov 1 '15 at 15:34

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.