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

#   Have Specific Custom Fields based on Variant

##

- **[SolarMade](/forum/user/37282-solarmade "View SolarMade's Profile")**
- [![SolarMade's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37282.jpg)](/forum/user/37282-solarmade "View SolarMade's Profile") Topic Author
- [ Offline](/forum/user/37282-solarmade)

Less More

- Posts: 31
- Thank you received: 3
-
-
- [](http://www.solarmade.com)
-

10 years 9 months ago [\#225841](#225841) by [SolarMade](/forum/user/37282-solarmade "View SolarMade's Profile")  *[Have Specific Custom Fields based on Variant](/forum/26-product-category-display/881420-have-specific-custom-fields-based-on-variant#225841 "-- url of the page with the problem -- :   www.solarmade.com/store/product/executive-windmill  -- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.4.45  Hello,  I am trying to achieve something for our customized products. The products can have custom engravings with 0,1,2 or 3 lines of engraving. Based on the number of lines the customer wants, the price will change. Therefore I have made variants in order to achieve this.  Now for the tricky part. I have made custom fields(text) where people can put in the desired text they would like us to engrave. I am trying to tie the specific custom field(s) to the specific variant but I am finding this hard to achieve. For example: If the customer does not want any engraving I don't want the custom fields to be displayed. If the customer wants one line of text (variant) I only want one custom field to be displayed. If the customer wants two lines of text I want two custom fields to be displayed and so on.  I have attached screen shots so you understand what I mean.  What is the best way to achieve this if I can? Thank you for your assistance.")* was created by *[SolarMade](/forum/user/37282-solarmade "View SolarMade's Profile")*

-- url of the page with the problem -- : [ www.solarmade.com/store/product/executive-windmill](http://www.solarmade.com/store/product/executive-windmill)
-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.4.45

Hello,

I am trying to achieve something for our customized products. The products can have custom engravings with 0,1,2 or 3 lines of engraving. Based on the number of lines the customer wants, the price will change. Therefore I have made variants in order to achieve this.

Now for the tricky part. I have made custom fields(text) where people can put in the desired text they would like us to engrave. I am trying to tie the specific custom field(s) to the specific variant but I am finding this hard to achieve. For example: If the customer does not want any engraving I don't want the custom fields to be displayed. If the customer wants one line of text (variant) I only want one custom field to be displayed. If the customer wants two lines of text I want two custom fields to be displayed and so on.

I have attached screen shots so you understand what I mean.

What is the best way to achieve this if I can? Thank you for your assistance.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODE0MjAtaGF2ZS1zcGVjaWZpYy1jdXN0b20tZmllbGRzLWJhc2VkLW9uLXZhcmlhbnQ/dG1wbD1tYXJrZG93bg==) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86284
- Thank you received: 14263
-
-

10 years 9 months ago [\#225919](#225919) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Have Specific Custom Fields based on Variant](/forum/26-product-category-display/881420-have-specific-custom-fields-based-on-variant#225919 "-- url of the page with the problem -- :   www.solarmade.com/store/product/executive-windmill  -- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.4.45  Hello,  I am trying to achieve something for our customized products. The products can have custom engravings with 0,1,2 or 3 lines of engraving. Based on the number of lines the customer wants, the price will change. Therefore I have made variants in order to achieve this.  Now for the tricky part. I have made custom fields(text) where people can put in the desired text they would like us to engrave. I am trying to tie the specific custom field(s) to the specific variant but I am finding this hard to achieve. For example: If the customer does not want any engraving I don't want the custom fields to be displayed. If the customer wants one line of text (variant) I only want one custom field to be displayed. If the customer wants two lines of text I want two custom fields to be displayed and so on.  I have attached screen shots so you understand what I mean.  What is the best way to achieve this if I can? Thank you for your assistance.")*

Hi,

There is no mechanism in HikaShop to have custom item fields display based on the selected variant.
So it will require some modification.
The easiest is to edit the file "show" of the view "product" via the menu Display&gt;Views and add some custom javascript code to the page to hide/display the custom fields using the hkAfterUpdateVariant javascript trigger.
You can register it like this:
window.Oby.registerAjax("hkAfterUpdateVariant", "my_custom_function");
where my_custom_function is the name of your custom function where you will check the value selected in the characteristic dropdown and then display/hide the fields based on that.

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

- **[SolarMade](/forum/user/37282-solarmade "View SolarMade's Profile")**
- [![SolarMade's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37282.jpg)](/forum/user/37282-solarmade "View SolarMade's Profile") Topic Author
- [ Offline](/forum/user/37282-solarmade)

Less More

- Posts: 31
- Thank you received: 3
-
-
- [](http://www.solarmade.com)
-

10 years 9 months ago [\#225937](#225937) by [SolarMade](/forum/user/37282-solarmade "View SolarMade's Profile")  Replied by *[SolarMade](/forum/user/37282-solarmade "View SolarMade's Profile")* on topic *[Have Specific Custom Fields based on Variant](/forum/26-product-category-display/881420-have-specific-custom-fields-based-on-variant#225937 "-- url of the page with the problem -- :   www.solarmade.com/store/product/executive-windmill  -- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.4.45  Hello,  I am trying to achieve something for our customized products. The products can have custom engravings with 0,1,2 or 3 lines of engraving. Based on the number of lines the customer wants, the price will change. Therefore I have made variants in order to achieve this.  Now for the tricky part. I have made custom fields(text) where people can put in the desired text they would like us to engrave. I am trying to tie the specific custom field(s) to the specific variant but I am finding this hard to achieve. For example: If the customer does not want any engraving I don't want the custom fields to be displayed. If the customer wants one line of text (variant) I only want one custom field to be displayed. If the customer wants two lines of text I want two custom fields to be displayed and so on.  I have attached screen shots so you understand what I mean.  What is the best way to achieve this if I can? Thank you for your assistance.")*

Thank you Nicolas,

Is there somewhere in the 419 Lines of code I should consider putting the code? ![:)](/media/kunena/emoticons/8.png ":)")

Also I should probably be using the my_custom_function for each of the four different custom fields. Correct!

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

10 years 8 months ago [\#227664](#227664) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Have Specific Custom Fields based on Variant](/forum/26-product-category-display/881420-have-specific-custom-fields-based-on-variant#227664 "-- url of the page with the problem -- :   www.solarmade.com/store/product/executive-windmill  -- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.4.45  Hello,  I am trying to achieve something for our customized products. The products can have custom engravings with 0,1,2 or 3 lines of engraving. Based on the number of lines the customer wants, the price will change. Therefore I have made variants in order to achieve this.  Now for the tricky part. I have made custom fields(text) where people can put in the desired text they would like us to engrave. I am trying to tie the specific custom field(s) to the specific variant but I am finding this hard to achieve. For example: If the customer does not want any engraving I don't want the custom fields to be displayed. If the customer wants one line of text (variant) I only want one custom field to be displayed. If the customer wants two lines of text I want two custom fields to be displayed and so on.  I have attached screen shots so you understand what I mean.  What is the best way to achieve this if I can? Thank you for your assistance.")*

Hi,

If you need to insert some javascript ; there is not really a very specific place to add it.
But the bottom of the view is generally more appropriate so you're sure that your code won't break the HTML or be included into a loop.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

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

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

[](#top)
