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

#   PHP Code in Custom Field?

##

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

Less More

- Posts: 10
- Thank you received: 0
-
-

12 years 4 months ago [\#160590](#160590) by [convergent](/forum/user/32499-convergent "View convergent's Profile")  *[PHP Code in Custom Field?](/forum/27-checkout/869065-php-code-in-custom-field#160590 "I am wondering if it is possible to use PHP to populate a dropdown in a custom field.  On my website, users register devices they have purchased through our distributors. The users can then purchase optional add-ons, which come in the form of activation keys which they enter in their device. These activation keys are specific to each individual device and are generated by a remote script.  When the user purchases an activation key I want them to be able to select the device they want to buy the key for as part of the checkout process. I have been able to create the custom field as a dropdown, but I am unable to find a way to populate the list with user-specific data from the DB.  Any help is appreciated.")* was created by *[convergent](/forum/user/32499-convergent "View convergent's Profile")*

I am wondering if it is possible to use PHP to populate a dropdown in a custom field.

On my website, users register devices they have purchased through our distributors. The users can then purchase optional add-ons, which come in the form of activation keys which they enter in their device. These activation keys are specific to each individual device and are generated by a remote script.

When the user purchases an activation key I want them to be able to select the device they want to buy the key for as part of the checkout process. I have been able to create the custom field as a dropdown, but I am unable to find a way to populate the list with user-specific data from the DB.

Any help is appreciated.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg2OTA2NS1waHAtY29kZS1pbi1jdXN0b20tZmllbGQ/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: 86290
- Thank you received: 14269
-
-

12 years 4 months ago [\#160595](#160595) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[PHP Code in Custom Field?](/forum/27-checkout/869065-php-code-in-custom-field#160595 "I am wondering if it is possible to use PHP to populate a dropdown in a custom field.  On my website, users register devices they have purchased through our distributors. The users can then purchase optional add-ons, which come in the form of activation keys which they enter in their device. These activation keys are specific to each individual device and are generated by a remote script.  When the user purchases an activation key I want them to be able to select the device they want to buy the key for as part of the checkout process. I have been able to create the custom field as a dropdown, but I am unable to find a way to populate the list with user-specific data from the DB.  Any help is appreciated.")*

Hi,

Instead of trying to populate an existing custom field type with data, I would recommend to create a new type of custom field that you would call for example "serial number" which would display a dropdown of the serial numbers of the current user. Then you could just create a new custom field of that type for the table item (in order to have it on the product page, when the user add the product to the cart) and the selected value would be carried on to the checkout, the order, the email notifications and the invoice.
To create such new types of custom field, you can develop a small plugin implementing our Fields API triggers: [ www.hikashop.com/support/support/documen...entation.html#fields](https://www.hikashop.com/support/support/documentation/62-hikashop-developer-documentation.html#fields)
You can find an example of such plugin with the latest version of HikaShop, in the folder plugins/hikashop/datepickerfield which adds the "plugin datepicker" type of custom fields in order to be able to create custom fields for date selection with advanced restrictions.

PS: I already replied to your contact request on the same question via email. You didn't receive it ?

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

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

[](#top)
