Some stores may want this behavior; however, if you'd rather have the "Discount" price be calculated after the "Special" price, you just need to switch the order in which the cart library calculates the specials and discounts. To do so, make the following change to your installation:
IN:
Code: Select all
/system/library/cart.php
Code: Select all
// Product Discounts
$discount_quantity = 0;
foreach ($this->session->data['cart'] as $key_2 => $quantity_2) {
$product_2 = explode(':', $key_2);
if ($product_2[0] == $product_id) {
$discount_quantity += $quantity_2;
}
}
$product_discount_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id . "' AND quantity <= '" . (int)$discount_quantity . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity DESC, priority ASC, price ASC LIMIT 1");
if ($product_discount_query->num_rows) {
$price = $product_discount_query->row['price'];
}
// Product Specials
$product_special_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1");
if ($product_special_query->num_rows) {
$price = $product_special_query->row['price'];
}
Code: Select all
// Product Specials
$product_special_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1");
if ($product_special_query->num_rows) {
$price = $product_special_query->row['price'];
}
// Product Discounts
$discount_quantity = 0;
foreach ($this->session->data['cart'] as $key_2 => $quantity_2) {
$product_2 = explode(':', $key_2);
if ($product_2[0] == $product_id) {
$discount_quantity += $quantity_2;
}
}
$product_discount_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id . "' AND quantity <= '" . (int)$discount_quantity . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity DESC, priority ASC, price ASC LIMIT 1");
if ($product_discount_query->num_rows) {
$price = $product_discount_query->row['price'];
}
1.4.x versions already prioritize the "Discount" over the "Special" price, so this edit is not needed.