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

#   Using a custom field in a variant product

##

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

Less More

- Posts: 100
- Thank you received: 1
-
-

13 years 8 months ago [\#94857](#94857) by [paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile")  *[Using a custom field in a variant product](/forum/2-general-talk-about-hikashop/79374-using-a-custom-field-in-a-variant-product#94857 "HI  I have the following setup  1 main product, 1 option and 2 variants.  I have created a custom field (called maximum&#95;place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.  I can't seem to figure out how to reference this field in the view product and file option.php.  I have tried  $optionElement-&gt;maximum&#95;place and $optionElement-&gt;main-&gt;maximum&#95;place but i get nothing...  Have i called it correctly.  Thanks  Patrick")* was created by *[paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile")*

HI

I have the following setup

1 main product, 1 option and 2 variants.

I have created a custom field (called maximum_place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.

I can't seem to figure out how to reference this field in the view product and file option.php.

I have tried

$optionElement-&gt;maximum_place and $optionElement-&gt;main-&gt;maximum_place but i get nothing...

Have i called it correctly.

Thanks

Patrick

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mzc0LXVzaW5nLWEtY3VzdG9tLWZpZWxkLWluLWEtdmFyaWFudC1wcm9kdWN0P3RtcGw9bWFya2Rvd24=) 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: 86587
- Thank you received: 14325
-
-

13 years 8 months ago [\#95021](#95021) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Using a custom field in a variant product](/forum/2-general-talk-about-hikashop/79374-using-a-custom-field-in-a-variant-product#95021 "HI  I have the following setup  1 main product, 1 option and 2 variants.  I have created a custom field (called maximum&#95;place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.  I can't seem to figure out how to reference this field in the view product and file option.php.  I have tried  $optionElement-&gt;maximum&#95;place and $optionElement-&gt;main-&gt;maximum&#95;place but i get nothing...  Have i called it correctly.  Thanks  Patrick")*

Hi,

If you want to have the value of custom field in the main product of the option, it should indeed be $optionElement-&gt;maximum_place or $optionElement-&gt;main-&gt;maximum_place but only inside the foreach($this-&gt;element-&gt;options as $optionElement){ block of code in the option.php file.
Outside that block is will be more complex.
Something like that:
$optionElement = reset($this-&gt;element-&gt;options);
echo $optionElement-&gt;main-&gt;maximum_place;

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

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

Less More

- Posts: 100
- Thank you received: 1
-
-

13 years 8 months ago -  13 years 8 months ago [\#95031](#95031) by [paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile")  Replied by *[paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile")* on topic *[Using a custom field in a variant product](/forum/2-general-talk-about-hikashop/79374-using-a-custom-field-in-a-variant-product#95031 "HI  I have the following setup  1 main product, 1 option and 2 variants.  I have created a custom field (called maximum&#95;place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.  I can't seem to figure out how to reference this field in the view product and file option.php.  I have tried  $optionElement-&gt;maximum&#95;place and $optionElement-&gt;main-&gt;maximum&#95;place but i get nothing...  Have i called it correctly.  Thanks  Patrick")*

HI Nicolas

I have used the following in the option.php file below line 86

$this-&gt;row-&gt;prices = array($variant-&gt;prices[$k]);
$optionElement = reset($this-&gt;element-&gt;options);
$text = $variant-&gt;start_date.$text;
$text.=" Remaining Spots " . $variant-&gt;product_quantity. " of " . $optionElement-&gt;main-&gt;maximum\_place . ' '.($positive?'+':'').strip_tags($this-&gt;loadTemplate());

However, I still don't get the value which has been set in the custom field in the Main product.

Am I still doing something incorrect.

Thanks

Patrick

Last edit: 13 years 8 months ago by [paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mzc0LXVzaW5nLWEtY3VzdG9tLWZpZWxkLWluLWEtdmFyaWFudC1wcm9kdWN0P3RtcGw9bWFya2Rvd24=) 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: 86587
- Thank you received: 14325
-
-

13 years 8 months ago [\#95054](#95054) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Using a custom field in a variant product](/forum/2-general-talk-about-hikashop/79374-using-a-custom-field-in-a-variant-product#95054 "HI  I have the following setup  1 main product, 1 option and 2 variants.  I have created a custom field (called maximum&#95;place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.  I can't seem to figure out how to reference this field in the view product and file option.php.  I have tried  $optionElement-&gt;maximum&#95;place and $optionElement-&gt;main-&gt;maximum&#95;place but i get nothing...  Have i called it correctly.  Thanks  Patrick")*

Is the value in the main product or in the option ?
If it's in the main product it should be either $this-&gt;element-&gt;maximum_place or $this-&gt;element-&gt;main-&gt;maximum_place

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

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

Less More

- Posts: 100
- Thank you received: 1
-
-

13 years 8 months ago [\#95245](#95245) by [paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile")  Replied by *[paddyrolls](/forum/user/1931-paddyrolls "View paddyrolls's Profile")* on topic *[Using a custom field in a variant product](/forum/2-general-talk-about-hikashop/79374-using-a-custom-field-in-a-variant-product#95245 "HI  I have the following setup  1 main product, 1 option and 2 variants.  I have created a custom field (called maximum&#95;place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.  I can't seem to figure out how to reference this field in the view product and file option.php.  I have tried  $optionElement-&gt;maximum&#95;place and $optionElement-&gt;main-&gt;maximum&#95;place but i get nothing...  Have i called it correctly.  Thanks  Patrick")*

HI Nicolas

Thank you for the information

The custom field was on the main product so $this-&gt;element-&gt;maximum_place worked.

![:)](/media/kunena/emoticons/3.png ":)")

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

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