Hi the Magento Community,
I would like to add a discount label on my pictures on my product pages : I already have one for each product on category page (see picture below) but not on product pages.
I took the code from the category, but I don’t know where I should paste it and if it will work with fotorama.
My question is : Is it possible and which file I need to edit ?
Here is the code (I use Porto Theme) :
< ?php
$product_label = "";
if($_product_label_config['sale_label']) {
$orgprice = $_product->getPrice();
$specialprice = $_product->getSpecialPrice();
$specialfromdate = $_product->getSpecialFromDate();
$specialtodate = $_product->getSpecialToDate();
$today = time();
if(!$specialprice)
$specialprice = $orgprice;
if($specialprice < $orgprice) {
if((is_null($specialfromdate) && is_null($specialtodate)) || ($today >= strtotime($specialfromdate) && is_null($specialtodate)) || ($today < = strtotime($specialtodate) && is_null($specialfromdate)) || ($today >= strtotime($specialfromdate) && $today < = strtotime($specialtodate))){
if($_product_label_config['sale_label_percent']) {
$save_percent = 100-round(($specialprice/$orgprice)*100);
$product_label .= ''.'-'.$save_percent.'%'.'
‘;
} else {
$product_label .= ‘
‘.$_product_label_config[‘sale_label_text’].’‘;
}
}
}
}
if($_product_label_config[‘new_label’]) {
$now = date(“Y-m-d”);
$newsFrom= substr($_product->getData(‘news_from_date’),0,10);
$newsTo= substr($_product->getData(‘news_to_date’),0,10);
if ($newsTo != ” || $newsFrom != ”){
if (($newsTo != ” && $newsFrom != ” && $now>=$newsFrom && $now< =$newsTo) || ($newsTo == '' && $now >=$newsFrom) || ($newsFrom == ” && $now< =$newsTo)) {
$product_label .= '
‘.$_product_label_config[‘new_label_text’].”;
}
}
}
if($product_label)
echo ‘‘.$product_label.’‘;
?>