[Skip to main content](#vessel-content)

#   Display product code to only registered users

##

- **[verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")**
- [![verzevoul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8351-verzevoul "View verzevoul's Profile") Topic Author
- [ Offline](/forum/user/8351-verzevoul)

Less More

- Posts: 1195
- Thank you received: 13
-
-

7 months 1 week ago [\#371361](#371361) by [verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")  *[Display product code to only registered users](/forum/26-product-category-display/910421-display-product-code-to-only-registered-users#371361 "-- 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!")* was created by *[verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")*

-- 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!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MTA0MjEtZGlzcGxheS1wcm9kdWN0LWNvZGUtdG8tb25seS1yZWdpc3RlcmVkLXVzZXJzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

7 months 1 week ago -  7 months 1 week ago [\#371364](#371364) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Display product code to only registered users](/forum/26-product-category-display/910421-display-product-code-to-only-registered-users#371364 "-- 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!")*

Hi,

The simplest approach would be to turn off the "Show product code" setting in Display &gt; Configuration &gt; 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 &gt; Views, find the file &#96;show_default.php&#96; 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:

&lt;?php if(!JFactory::getUser()-&gt;guest &amp;&amp; !empty($this-&gt;element-&gt;product_code)) { ?&gt; &lt;span class="hikashop_product_code_main"&gt;&lt;?php echo $this-&gt;element-&gt;product_code; ?&gt;&lt;/span&gt; &lt;?php } ?&gt;

You can do the same in the listing layout (e.g. &#96;listing_img_title.php&#96;) if you also want to show the code on category pages for registered users but you need to change $this-&gt;element to $this-&gt;row

Last edit: 7 months 1 week ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

The following user(s) said Thank You: [verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MTA0MjEtZGlzcGxheS1wcm9kdWN0LWNvZGUtdG8tb25seS1yZWdpc3RlcmVkLXVzZXJzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")**
- [![verzevoul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8351-verzevoul "View verzevoul's Profile") Topic Author
- [ Offline](/forum/user/8351-verzevoul)

Less More

- Posts: 1195
- Thank you received: 13
-
-

7 months 1 week ago [\#371366](#371366) by [verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")  Replied by *[verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")* on topic *[Display product code to only registered users](/forum/26-product-category-display/910421-display-product-code-to-only-registered-users#371366 "-- 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!")*

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.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MTA0MjEtZGlzcGxheS1wcm9kdWN0LWNvZGUtdG8tb25seS1yZWdpc3RlcmVkLXVzZXJzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

7 months 1 week ago [\#371368](#371368) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Display product code to only registered users](/forum/26-product-category-display/910421-display-product-code-to-only-registered-users#371368 "-- 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!")*

Right. I've updated my message for the listing.

The following user(s) said Thank You: [verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MTA0MjEtZGlzcGxheS1wcm9kdWN0LWNvZGUtdG8tb25seS1yZWdpc3RlcmVkLXVzZXJzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.053 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
