Описываю схему вывода скидок в зависимости от количества товара в корзине.
--------------------------------
Для начала заходим в файл system/cart/cart.php
находим строчку
public function add($product_id, $quantity = 1, $option = array(), $recurring_id = 0) {
и перед ней вставляем этот код:
public function getProductDiscountsCart($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC");
return $query->rows;
}
Далее идем в файл catalog/controller/checkout/cart.php
Находим строчку
$data['products'][] = array(
и перед ней вставляем этот код:
//Discounts
$discounts_info = $this->cart->getProductDiscountsCart($product['product_id']);
$discounts = array();
foreach ($discounts_info as $discount) {
$discounts[] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
);
}
Далее снова находим строчку
$data['products'][] = array(
И после вставляем этот код:
'discounts' => $discounts,
'tax_class_id' => $product['tax_class_id'],
Переходим в файл представления catalog/view/theme/default/template/checkout/cart.tpl
И в необходимом месте корзины выводим
<?php if ($product['discounts']) { ?>
<?php foreach ($product['discounts'] as $discount) { ?>
<p>от <?php echo $discount['quantity'] ?> шт. <?php echo $discount['price'] ?></p>
<?php } ?>
<?php } ?>
код должен находиться в цикле
<?php foreach ($products as $product) { ?>