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:
<?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