PHP Code in Custom Field?

  • Posts: 10
  • Thank you received: 0
10 years 11 months ago #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.

Please Log in or Create an account to join the conversation.

  • Posts: 83932
  • Thank you received: 13588
  • MODERATOR
10 years 11 months ago #160595

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
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 or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum