I'm trying to add an icon to all products with special price in a cart and I've to check if products are on sale. Anyone got any idea how to do it? It was simple to do in list and product cart but now I'm stuck.

1 Answer 1


You can do this by below code:

    // product in sales

If want only basic of Special price,Then you can try the below:

$specialprice = $product->getSpecialPrice();
$specialPriceFromDate = $product->getSpecialFromDate();
$specialPriceToDate = $product->getSpecialToDate();
$today =  time();

if ($specialprice && ($product->getPrice()>$product->getFinalPrice())):
        if($today >= strtotime( $specialPriceFromDate) && $today <= strtotime($specialPriceToDate) || 
    $today >= strtotime( $specialPriceFromDate) && is_null($specialPriceToDate)):
   //product in sales

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.