Skip to main content

use "date format" twice for numbers

More
7 years 7 months ago #303608 by n00bster
-- HikaShop version -- : 4.0.2

hi. i need to get this type of order and invoice number:
Code:
{date format="dm"}-AB{date format="y"}-{order_id} {date format="dm"}-RE{date format="y"}-{order_id}
but it looks like that only one "date format" placeholder are working in the number fields, is this a bug or a feature?
the output is:
Code:
0802-AB{date format="y"}-13 0802-RE{date format="y"}-13

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

More
7 years 7 months ago - 7 years 7 months ago #303609 by nicolas
Hi,

It's neither a bug nor a feature. It's something we just didn't thought would be needed and thus isn't implemented.
Now looking at the code it should be quite easy to add.

Change the code:
Code:
if(preg_match('#\{date *format ?= ?(?:"|\')(.*)(?:"|\') *\}#Ui',$format,$matches)) { $format = str_replace($matches[0],date($matches[1],$data->order_modified),$format); }
to:
Code:
if(preg_match_all('#\{date *format ?= ?(?:"|\')(.*)(?:"|\') *\}#Ui',$format,$matches)) { foreach($matches[0] as $k => $match) { $format = str_replace($match,date($matches[1][$k],$data->order_modified),$format); } }
in the file administrator/components/com_hikashop/helpers/helper.php and that should do it.
Last edit: 7 years 7 months ago by Jerome.
The following user(s) said Thank You: n00bster

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

More
7 years 7 months ago #303627 by n00bster
your snippet works perfect. is this code getting in the core?

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

More
7 years 7 months ago #303653 by nicolas
Hi,

Now that you confirmed it works, yes, it will be in the next version :)
The following user(s) said Thank You: n00bster

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

Time to create page: 0.199 seconds
Powered by Kunena Forum