Пример модуля "Рекомендуемые" (остальные по аналогии) для OpenCart 3:
1) catalog/controller/extension/module/featured.php
Ищем:
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
Меняем на:
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
$percent_discount = 100 - $this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')) * 100 / $this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')) . '%';
} else {
$special = false;
$percent_discount = false;
}
Ищем:
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
Меняем на:
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'percent_discount' => $percent_discount,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
2) catalog/view/theme/*/template/extension/module/featured.twig
В нужное место вставляем:
{% if product.percent_discount %}{{ product.percent_discount }}{% endif %}