Answer the question
In order to leave comments, you need to log in
How to add a percentage discount sticker for open cards 3?
There is a sticker in the top right corner, I want to add something like that, are there any modules, or how to do it yourself, who can tell me if there are styles for it)
Answer the question
In order to leave comments, you need to log in
An example of the "Featured" module (others by analogy) for OpenCart 3:
1) catalog/controller/extension/module/featured.php
Looking for:
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'])
);
{% if product.percent_discount %}{{ product.percent_discount }}{% endif %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question