The first thing to do is get the discount pulled from the database. In catalog/controller/home.php, there's loop to iterate over all the objects: foreach ($results as $result) {. On the line after that, add the following code:
Code: Select all
$product_discount = $database->getRow("select * from product_discount where product_id = '" . (int)$result['product_id'] . "' ORDER BY quantity ASC LIMIT 1");
if (!$product_discount) {
$discount = 0;
} else {
$discount = $product_discount['discount'];
}
Inside the $product_data[] = array() definition, add:
Code: Select all
'discount' => $discount,
'discount_price' => $currency->format($tax->calculate($result['price'] - $discount, $result['tax_class_id']))
In your template directory, edit content/home.tpl
Change this line that displays each item:
Code: Select all
<div class="products"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a><br /><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a><br /><?php echo $product['price']; ?></div>
Code: Select all
<div class="products"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a><br /><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a><br />
<?php if (!$product['discount']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price_old"><?php echo $product['price']; ?></span>
<span class="price_new"><?php echo $product['discount_price']; ?></span>
<?php } ?> </div>
Let me know if this works for you.