Jump to content

Prestashop 1.7.7.8 - Show customer group in Account page (Front End)


CdF-grafica

Recommended Posts

 

hshaker merci beaucoup pour ta réponse!

I explain our need better.
We apply a discount to those who subscribe to one of our printed magazines.
Who is subscribed to our magazine, we insert him in the "Customer group" "Subscriber".
Now the user, when he accesses his account, does not see the group he belongs to (so he cannot see if he is included in the "Subscribers" group).

What I would like is that, as information, it is written (in the account page frontend) for example:
You belong to the group: "Subscriber" (or "Customer", etc.).

How can I show the assigned "Customer group"? Thanks again.

Link to comment
Share on other sites

Tray This 

go to my-account.tpl an add this code

{assign var="defaultGroupID" value=Customer::getDefaultGroupId((int)$cookie->id_customer)}
{if $defaultGroupID=="1"}
  {assign var="defaultGroupName" value="YourGroupName"}
{elseif $defaultGroupID=="2"}
  {assign var="defaultGroupName" value="YourGroupName"}
{elseif $defaultGroupID=="3"}
  {assign var="defaultGroupName" value="YourGroupName"}
{/if}
<h1 class="h1">{l s='My account'} <span id="GroupName" class="{$defaultGroupName|lower}">Partenaire {$defaultGroupName}</span></h1>

Adapted 

$defaultGroupID=="" to your defaultGroupID
 value="YourGroupName" to your group name

 

Link to comment
Share on other sites

We want to tell you that it is possible to display customer groups on the account page by modifying the Prestashop core code.
Images and File paths for your reference are mentioned below:
https://nimbusweb.me/nimbus-screenshots/a5eed04b0c61821cb09f9c85f13cb3e6

File path: YOUR_PS_DIRECTORY/controllers/front/MyAccountController.php
https://nimbusweb.me/nimbus-screenshots/438a733a0fb87246cfca5a010be68c6a

File path: YOUR_PS_DIRECTORY/themes/YOUR_THEME/templates/customer/my-account.tpl
https://nimbusweb.me/nimbus-screenshots/f9c3245299b5c164cdecc654e0de8beb

  • Thanks 1
Link to comment
Share on other sites

  • 7 months later...

Hi Knowband Plugins

That works perfectly!
One question though: I would prefer to see the information on the "informations" section of "my account". Just putting the code into identity.tpl instead of my-account.tpl only gave me the result of
Customer Group: (without an indication of the group name here).

What am I missing?

And also: this code only brings the default customer group over. How would you alter the code to show all customer groups a specific customer group is attached to?

Kind Regards

Link to comment
Share on other sites

  • 10 months later...

Please add the below code in the following files

1. controllers\front\IdentityController.php

$new_customer_obj = new Customer($this->context->customer->id);
        $customer_groups = "";
        foreach($new_customer_obj->getGroups() as $key => $data){
            $group = new group($data);
            $name = $group->name[$this->context->language->id];
            $customer_groups .= $name.',';
        }
        $this->context->smarty->assign('groups_name', $customer_groups);

Screenshot https://nimb.ws/SpMdRq

2. \themes\{Your-theme}\templates\customer\_partials\customer-form.tpl

 <div class='form-group row' style="text-align: center;">
           {l s='Customer Groups ' d='Shop.Theme.Actions'}: {$groups_name}
      </div>

Screenshot : https://nimb.ws/Gw2dAn

 

It look Like : https://nimb.ws/ZBPbiE 

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...