OC 3.0.4.1
PHP 8.2
Keep Smiling
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Customer Group Special + Discount Display</name>
<code>customer_group_special_with_display</code>
<version>1.0</version>
<author>khnaz35</author>
<link>mailto:khnaz35@gmail.com</link>
<!-- Modify controller logic -->
<file path="catalog/controller/product/product.php">
<!-- Inject customer group price logic before special block -->
<operation>
<search><![CDATA[
if (!is_null($product_info['special']) && (float)$product_info['special'] >= 0) {
]]></search>
<add position="before"><![CDATA[
$data['price_value'] = (float)$product_info['price'];
$this->load->model('catalog/product');
// Default special price
$customer_group_special = $product_info['special'];
$specials = $this->model_catalog_product->getProductSpecials([
'filter_product_id' => $product_info['product_id']
]);
foreach ($specials as $s) {
if ((int)$s['customer_group_id'] === (int)$this->customer->getGroupId()) {
$customer_group_special = $s['price'];
break;
}
}
]]></add>
</operation>
<!-- Replace special price assignment with customer-group version -->
<operation>
<search><![CDATA[
$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']);
]]></search>
<replace><![CDATA[
$data['special'] = $this->currency->format($this->tax->calculate($customer_group_special, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
$data['special_value'] = (float)$customer_group_special;
]]></replace>
</operation>
</file>
<!-- Inject 'You save %' into product.twig after special price -->
<file path="catalog/view/theme/*/template/product/product.twig">
<operation>
<search><![CDATA[<h2>{{ special }}</h2>]]></search>
<add position="after"><![CDATA[
{% if price_value and special_value and price_value > special_value %}
<li><strong class="price-saving">You save {{ ((price_value - special_value) / price_value * 100)|round }}%</strong></li>
{% endif %}
]]></add>
</operation>
</file>
</modification>
Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature
1-copy the code and create new xml from your admin modification section you have extension installed for that on your store.
2- copy the code past into a file using text editor name the file and save it as .xml and place the file inside system directory
Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature
I figured out option 1 thank youkhnaz35 wrote: ↑Sun Jul 20, 2025 1:21 pmYou have to options
1-copy the code and create new xml from your admin modification section you have extension installed for that on your store.
2- copy the code past into a file using text editor name the file and save it as .xml and place the file inside system directory
After saving it says error then if I click blue refresh button it crashes admin, I had to uninstall it.
OC 3.0.4.1
PHP 8.2
Keep Smiling
Awesome most welcome
So now on this part
As i mentioned earlier i didn't test it on my test store , it was most logical that would be done.lockiedownunder wrote: ↑Sun Jul 20, 2025 1:54 pmAfter saving it says error then if I click blue refresh button it crashes admin, I had to uninstall it.
So make things work i need to know the exact error what you got after installing it.
Do share the error logs
Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature
OC 3.0.4.1
PHP 8.2
Keep Smiling
Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature
Tony
OC 3.0.4.1
PHP 8.2
Keep Smiling
This error would be on server error logs not in your opencart logslockiedownunder wrote: ↑Sun Jul 20, 2025 6:30 pmAfter install I press blue refresh button and get the attached screen.
Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature
Most welcome, if no need further solution I will mark the topic as closedlockiedownunder wrote: ↑Sun Jul 20, 2025 6:31 pmIt's okay don't waste any more time on this. I thank you for your assistance so far.
Tony
Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature
Users browsing this forum: ianhaney50 and 17 guests