Skip to Content

New J2Commerce 6.6.5 is out. Here is everything in the release.

See What’s New
Account
Enter the email address on your account.
Forgot your username?
Enter your password.
Forgot your password?

Or continue with

Closed Public Category: Technical Support / Bugs Ticket #476

How to add a message to customer profile page?

This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Conversation

Antonio Cornacchia

Hello

is it possibile to add a message to the customer profile page? I need to add a simple text editable by me as admin.

Regards

Olivier Buisard Staff

Hi Antonio,

the best way, I think, is to create a custom html module that you can assign to the 'My profile' menu item that you have created. The position of the module will depend on what the template you are using allows you to do.

You can also create a template override of the page, but in my opinion, it is more maintenance down the road. 

Olivier.

Antonio Cornacchia

Hi Olivier, thanks for the suggestion but I need to assign a (potentially) different message for every customers, without to create a module for every customers. I also thought about a user extra field that can only be edited by the admin, but I don't know if it's possible to display it on the customer information page.

Olivier Buisard Staff

Ok, that sounds very manual intensive, no matter how it will be done...
I suppose one way to do this would be to create a user custom field, get that field in an override of the profile page and show it.

Olivier.

Antonio Cornacchia

Okay Olivier, I'll try. Which file should I override?
There are no user or profile folders in administrator/components/com_j2store/views.

Antonio Cornacchia

I found it! I prefer to add the custom field in ordersummary.php

please Olivier, can you help me? what code should I add to show an "Example" custom field?

Thanks a lot.

Olivier Buisard Staff

Ok, to get custom fields in the override, I would do something like:

$user = Factory::getApplication()->getIdentity();

$jFields = Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields('com_users.user', $user, true); // Get all cutom fields of User context for the current user.

foreach($jFields as $jfield) { // make the fields easier to access
    $jFields[$jfield->name] = $jfield;
}

Then it is just a matter to do an echo $jFields['your-custom-field-name']->rawvalue; // or use ->value

to get the value.

Olivier.

Antonio Cornacchia

Thanks Olivier, with your suggestion and Gemini's help, I managed to get what I needed. Now the user fields are visible on the MyProfile page after the order list.