Dynamic radio custom field

  • Posts: 200
  • Thank you received: 13
2 years 2 months ago #347323

-- HikaShop version -- : 4.7
-- Joomla version -- : 4.2.5
-- PHP version -- : 8.1

hi

is there any possibility in hikashop to create a custom field of the type radio or dropdown which its options are created dynamicly with PHP ??

i need to create a dynamic radio group custom field with 7 items of 7 days from today untill next 6 days (with showing the date)

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

  • Posts: 83338
  • Thank you received: 13476
  • MODERATOR
2 years 2 months ago #347327

Hi,

Sure. Create a custom field of the type radio, and under the "data" area, select "MySQL query", and enter the MySQL query:

SELECT CURRENT_DATE() AS value UNION SELECT CURRENT_DATE() + INTERVAL 1 DAY UNION SELECT CURRENT_DATE() + INTERVAL 2 DAY UNION SELECT CURRENT_DATE() + INTERVAL 3 DAY UNION SELECT CURRENT_DATE() + INTERVAL 4 DAY UNION SELECT CURRENT_DATE() + INTERVAL 5 DAY UNION SELECT CURRENT_DATE() + INTERVAL 6 DAY
That will dynamically load the date of the current day plus the next 6 days in the custom field. That will be easier than creating a custom type of custom fields with the development of a plugin.

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

  • Posts: 200
  • Thank you received: 13
2 years 2 months ago #347338

great

i was thinking that sql query can only get existing data from database ...

this is very good,

but i have another question. is there any way to wrtie some php code here ? i need to show the date in JHtML::date() to convert date in my desired format

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

  • Posts: 83338
  • Thank you received: 13476
  • MODERATOR
2 years 2 months ago #347339

Hi,

Yes, you can write PHP code. As I said you'll need to develop a custom Joomla plugin for that, and implement the Fields API of HikaShop to add your own custom field type:
www.hikashop.com/support/documentation/6...entation.html#fields
You can base yourself on the plugins/hikashop/datepickerfield/ files which add the "advanced date picker" type to the custom fields.

The following user(s) said Thank You: khashiz

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

Time to create page: 0.058 seconds
Powered by Kunena Forum