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

#   how to display variables in product id in product page

##

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

Less More

- Posts: 20
- Thank you received: 0
-
-

5 years 3 weeks ago [\#336320](#336320) by [farzadfarzad](/forum/user/55939-farzadfarzad "View farzadfarzad's Profile")  *[how to display variables in product id in product page](/forum/26-product-category-display/903314-how-to-display-variables-in-product-id-in-product-page#336320 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 4.0.3 -- PHP version -- : 7.4 -- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page  hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product.  Thank you for guiding me.")* was created by *[farzadfarzad](/forum/user/55939-farzadfarzad "View farzadfarzad's Profile")*

-- HikaShop version -- : 4.4.4
-- Joomla version -- : 4.0.3
-- PHP version -- : 7.4
-- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page

hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product. Code:

echo $this-&gt;element-&gt;product_id;

Thank you for guiding me.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDMzMTQtaG93LXRvLWRpc3BsYXktdmFyaWFibGVzLWluLXByb2R1Y3QtaWQtaW4tcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86358
- Thank you received: 14293
-
-

5 years 3 weeks ago [\#336326](#336326) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[how to display variables in product id in product page](/forum/26-product-category-display/903314-how-to-display-variables-in-product-id-in-product-page#336326 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 4.0.3 -- PHP version -- : 7.4 -- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page  hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product.  Thank you for guiding me.")*

Hi,

Are you talking about variants ?
The variants data is available in $this-&gt;element-&gt;variants
This is an array of variant objects.
So you can do it like that: Code:

foreach($this-&gt;element-&gt;variants as $variant) { echo $variant-&gt;product_id; }

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

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

Less More

- Posts: 20
- Thank you received: 0
-
-

5 years 3 weeks ago [\#336330](#336330) by [farzadfarzad](/forum/user/55939-farzadfarzad "View farzadfarzad's Profile")  Replied by *[farzadfarzad](/forum/user/55939-farzadfarzad "View farzadfarzad's Profile")* on topic *[how to display variables in product id in product page](/forum/26-product-category-display/903314-how-to-display-variables-in-product-id-in-product-page#336330 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 4.0.3 -- PHP version -- : 7.4 -- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page  hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product.  Thank you for guiding me.")*

hi
thank you for reply.
I want the ID of each variant of the product to be displayed by selecting the desired variant. With the following code, all product IDs of all variants are displayed together!
For example, I have a product with the ID 650 and the ID of its variants, respectively, equal to 651/652/653/654, now with the code you gave, the following number is displayed in one place.
650651652653654
Do you understand what I mean?
I want product id (variant ) for each variants to be displayed dynamically.
thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDMzMTQtaG93LXRvLWRpc3BsYXktdmFyaWFibGVzLWluLXByb2R1Y3QtaWQtaW4tcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86358
- Thank you received: 14293
-
-

5 years 3 weeks ago [\#336331](#336331) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[how to display variables in product id in product page](/forum/26-product-category-display/903314-how-to-display-variables-in-product-id-in-product-page#336331 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 4.0.3 -- PHP version -- : 7.4 -- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page  hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product.  Thank you for guiding me.")*

Hi,

Well, then you can add your code in product / show.php via the menu Display&gt;Views.
For example, if you want to add the product_id of the current variant just after the product name on the product page, you can change the line:
echo $variant-&gt;product_name;
to:
echo $variant-&gt;product_name. ' ' . $variant-&gt;product_id;

When you select a variant, the name will change and the id displayed there too.

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

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

Less More

- Posts: 20
- Thank you received: 0
-
-

5 years 3 weeks ago [\#336342](#336342) by [farzadfarzad](/forum/user/55939-farzadfarzad "View farzadfarzad's Profile")  Replied by *[farzadfarzad](/forum/user/55939-farzadfarzad "View farzadfarzad's Profile")* on topic *[how to display variables in product id in product page](/forum/26-product-category-display/903314-how-to-display-variables-in-product-id-in-product-page#336342 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 4.0.3 -- PHP version -- : 7.4 -- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page  hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product.  Thank you for guiding me.")*

Hi
I added the following code in the view show_tabular.php but it does not show anything!
&lt;?php echo $variant-&gt;product_name. ' ' . $variant-&gt;product_id; ?&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDMzMTQtaG93LXRvLWRpc3BsYXktdmFyaWFibGVzLWluLXByb2R1Y3QtaWQtaW4tcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86358
- Thank you received: 14293
-
-

5 years 3 weeks ago [\#336350](#336350) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[how to display variables in product id in product page](/forum/26-product-category-display/903314-how-to-display-variables-in-product-id-in-product-page#336350 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 4.0.3 -- PHP version -- : 7.4 -- Error-message(debug-mod must be tuned on) -- : how to display variables in product id in product page  hiI was able to display the product ID on the product page via the following code. But I want for products that have variety. Display the ID of each variety of product.  Thank you for guiding me.")*

Hi,

That's normal. I talked about code to replace, not add, and I talked about product / show.php not product / show_tabular.php
Please follow the instructions.

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDMzMTQtaG93LXRvLWRpc3BsYXktdmFyaWFibGVzLWluLXByb2R1Y3QtaWQtaW4tcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) 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.093 seconds

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