- Posts: 1195
- Thank you received: 13
Display product code to only registered users
7 months 1 week ago #371361
by verzevoul
Display product code to only registered users was created by verzevoul
-- HikaShop version -- : 6.4.0
-- Joomla version -- : 5.4.3
-- PHP version -- : 8.3
Hi!
I'm building a B2B eshop, so i need to hide the product code from public group and display it to only registered users.
How can i do that?
Thank you!
-- Joomla version -- : 5.4.3
-- PHP version -- : 8.3
Hi!
I'm building a B2B eshop, so i need to hide the product code from public group and display it to only registered users.
How can i do that?
Thank you!
Please Log in or Create an account to join the conversation.
7 months 1 week ago - 7 months 1 week ago #371364
by nicolas
Replied by nicolas on topic Display product code to only registered users
Hi,
The simplest approach would be to turn off the "Show product code" setting in Display > Configuration > Product page, so that the product code is hidden everywhere by default (product page, cart, emails, invoices, etc.).
Then, create a view override to display it only for logged-in users where you want it. Go to Display > Views, find the file `show_default.php` in the product view (or whichever layout you use), and click "Edit" to create an override.
In the override, add the following code where you want the product code to appear:
You can do the same in the listing layout (e.g. `listing_img_title.php`) if you also want to show the code on category pages for registered users but you need to change $this->element to $this->row
The simplest approach would be to turn off the "Show product code" setting in Display > Configuration > Product page, so that the product code is hidden everywhere by default (product page, cart, emails, invoices, etc.).
Then, create a view override to display it only for logged-in users where you want it. Go to Display > Views, find the file `show_default.php` in the product view (or whichever layout you use), and click "Edit" to create an override.
In the override, add the following code where you want the product code to appear:
Code:
<?php if(!JFactory::getUser()->guest && !empty($this->element->product_code)) { ?>
<span class="hikashop_product_code_main"><?php echo $this->element->product_code; ?></span>
<?php } ?>
You can do the same in the listing layout (e.g. `listing_img_title.php`) if you also want to show the code on category pages for registered users but you need to change $this->element to $this->row
Last edit: 7 months 1 week ago by nicolas.
The following user(s) said Thank You: verzevoul
Please Log in or Create an account to join the conversation.
7 months 1 week ago #371366
by verzevoul
Replied by verzevoul on topic Display product code to only registered users
Great thank you!
What about product's listing page?
I added the code in the view file listing_img_title.php but didn't work.
What about product's listing page?
I added the code in the view file listing_img_title.php but didn't work.
Please Log in or Create an account to join the conversation.
7 months 1 week ago #371368
by nicolas
Replied by nicolas on topic Display product code to only registered users
Right. I've updated my message for the listing.
The following user(s) said Thank You: verzevoul
Please Log in or Create an account to join the conversation.
Time to create page: 0.069 seconds