@wolf65
Начинающий Frontend

Как добавить наклейку скидки в процентах опен карт 3?

5ee0eaa4eed4e493805258.jpeg
Сверху в правом углу наклейка, хочу добавить что-тог подобное, есть ли модули, или как сделать это самостоятельно кто может подсказать, стили к ней есть если что)
  • Вопрос задан
  • 160 просмотров
Решения вопроса 1
@secretsergey
Пример модуля "Рекомендуемые" (остальные по аналогии) для 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 %}
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
wapster92
@wapster92 Куратор тега CSS
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы