Date Custom fields

  • Posts: 48
  • Thank you received: 3
7 months 3 days ago #360484

-- HikaShop version -- : 5.0.4
-- Joomla version -- : 5.1.0
-- PHP version -- : 8.1

can you please assist on creating a radio buttons custom field on checkout page with dynamic valuse of 7 days i a row from tomorrow ?

suppose today is 4/22/2024

i need to create a custom field of type radio in checkout page with this values :

Tomorrow (4/23/2024)
The day after tomrrow (4/24/2024)
4/25/2024
4/26/2024
4/27/2024
4/28/2024
4/29/2024

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
7 months 3 days ago #360486

Hi,

In the data area of your custom field, instead of entering values, you can provide a MySQL query.
There, you can provide a MySQL query to generate the dates.
For example:

SELECT CONCAT('Tomorrow (',DATE_FORMAT(CURDATE() + INTERVAL 1 DAY, '%d/%m/%Y'),')') as value UNION SELECT CONCAT('The day after tomorrow (',DATE_FORMAT(CURDATE() + INTERVAL 2 DAY, '%d/%m/%Y'),')') UNION SELECT DATE_FORMAT(CURDATE() + INTERVAL 3 DAY, '%d/%m/%Y') UNION SELECT DATE_FORMAT(CURDATE() + INTERVAL 4 DAY, '%d/%m/%Y') UNION SELECT DATE_FORMAT(CURDATE() + INTERVAL 5 DAY, '%d/%m/%Y') UNION SELECT DATE_FORMAT(CURDATE() + INTERVAL 6 DAY, '%d/%m/%Y') UNION SELECT DATE_FORMAT(CURDATE() + INTERVAL 7 DAY, '%d/%m/%Y') UNION SELECT DATE_FORMAT(CURDATE() + INTERVAL 8 DAY, '%d/%m/%Y');
References:
www.w3schools.com/sql/func_mysql_curdate.asp
www.w3schools.com/sql/func_mysql_date_format.asp
dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html
www.w3schools.com/sql/func_mysql_concat.asp
dev.mysql.com/doc/refman/8.0/en/union.html

Last edit: 7 months 3 days ago by nicolas.
The following user(s) said Thank You: demoisellegol

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

Time to create page: 0.044 seconds
Powered by Kunena Forum