PDA

View Full Version : [Core Hack] Corner banners now show MSRP savings value



Fyod
10-03-2012, 02:19 PM
I often ask questions here, so I think I should contribute to the community.

In my case, I want to show customers the percentage amount they save in comparison to buying from the usual manufacturer. So I thought it would be good to show that using the corner banner. If I have my own product on sale, that is shown by strikethrough old price above the new price.
Of course back up files before you make changes.


in catalog/includes/modules/product_listing.php (line 325 through 337) and/or product_listing_col.php (line 264 through 276)

replace


// Special Offer Price Corner Banner
if (CB_SPECIALS == 'true') {
if ($pf->hasSpecialPrice() == true) {
//Find out discount and round to nearest 5
$fullprice = $pf->getPrice();
$saleprice = $pf->specialPrice();
$discount = (((($fullprice * 100) - ($saleprice * 100)) / ($fullprice * 100)) * 100);
$rounded_discount = floor($discount / 5) * 5;
if ($rounded_discount >= CB_SPECIALS_NO) {
$lc_text = '<img class="corner_banner" src="' . DIR_WS_IMAGES . 'corner_banners/' . $language . '/save' . $rounded_discount . '.png" alt="">';
}
}
}

with


// MSRP Savings Corner Banner
if (tep_not_null($listing[$x]['products_msrp'])) { // if product MSRP is more than zero
$fullprice = $listing[$x]['products_msrp']; // grabs MSRP from DB
$saleprice = $listing[$x]['products_price']; // product price from DB
$discount = ((($fullprice - $saleprice) / $fullprice) * 100); // counts percentage
$rounded_discount = floor($discount / 5) * 5; // rounds up to nearest 5%
$lc_text = '<img class="corner_banner" src="' . DIR_WS_IMAGES . 'corner_banners/' . $language . '/save' . $rounded_discount . '.png" alt="">';
}

Optionally, if you want to make separate corner banners for MSRP savings, change '/save' to '/msrp'.
Then make sure to name your images ie. "msrp20.png", the number being the savings percentage.

Featured, call for price, out of stock, last few, top rated corner banners have the same functionality as before.