Post by Photospirit » Fri Sep 22, 2017 3:35 pm

Hi,
I want to show my calculated discount on the product page only to logged in users beloging to a certain customer group.
My code currently works fine for all users logged in. So how can I limit it to a certain customer group.

Code: Select all

<?php if (!$logged) { ?>
<?php } else { ?>
<h5>Ihr Rabatt für dieses Produkt: <strong><?php echo round((($priceInt[0]-$specialInt[0])/$priceInt[0])*100,1);  ?>%</strong></h5>
<?php } ?> 
It should be enhanced that if customer does not belong to customer_group_id == 1 then the calculated discount is not shown.
Thanks, Chris

New member

Posts

Joined
Sat Oct 23, 2010 8:16 pm

Post by paulfeakins » Fri Sep 22, 2017 5:38 pm

Somewhere in the product controller (catalog/controller/product/product.php) add:

Code: Select all

$data['customer_group_id'] = $this->customer->getGroupId();
Then anywhere in your product template (product.tpl) you will be able to access the group ID with:

Code: Select all

$customer_group_id
Ideally make these changes with vQmod to avoid editing core files.

Hope that helps!

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Photospirit » Fri Sep 22, 2017 5:58 pm

Hi Paul...thanks...that helped.

New member

Posts

Joined
Sat Oct 23, 2010 8:16 pm

Post by paulfeakins » Fri Sep 22, 2017 7:25 pm

Great stuff, thanks Chris!

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 182 guests