use "date format" twice for numbers

  • Posts: 103
  • Thank you received: 5
5 years 2 months ago #303608

-- HikaShop version -- : 4.0.2

hi. i need to get this type of order and invoice number:

{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:
0802-AB{date format="y"}-13
0802-RE{date format="y"}-13

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 2 months ago #303609

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:

		if(preg_match('#\{date *format ?= ?(?:"|\')(.*)(?:"|\') *\}#Ui',$format,$matches)) {
			$format = str_replace($matches[0],date($matches[1],$data->order_modified),$format);
		}
to:
		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: 5 years 2 months ago by Jerome.
The following user(s) said Thank You: n00bster

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

  • Posts: 103
  • Thank you received: 5
5 years 2 months ago #303627

your snippet works perfect. is this code getting in the core?

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 2 months ago #303653

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.064 seconds
Powered by Kunena Forum