Answer the question
In order to leave comments, you need to log in
Opencart 2.3 display discount percentage?
I'm trying to display what percentage of the discount in the product CARD
added to the controller (highlighted what I added)
if ((float)$product_info['special']) {
$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
$data['discount_amount'] = $this->currency->format($this->tax->calculate(($product_info['price'] - $product_info['special']), $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
// Сюда вставил $data['skidka'] = round(100-($product_info['special']/($product_info['price']/100)));</b>
} else {
$data['special'] = false;
// Сюда вставил $data['skidka'] = false;
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
// Сюда вставил 'skidka' => $skidka,
'tax' => $tax,
'sku' => (empty($result['sku'])) ? '' : $this->language->get('text_sku') .' '. $result['sku'],
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
);
}
<span>- echo $skidka; %</span>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question