Order_id tag in invoice number format

  • Posts: 171
  • Thank you received: 9
10 years 1 month ago #173643

-- HikaShop version -- : 2.3.3.
-- HikaMarket version -- : 1.4.4
-- Joomla version -- : 3.3.4.

Hi,

We wanted to use {order_id} tag in in invoice number format, but there we can not set parameter size=5. But as we have {id size="5"} in order number format, we should need this size feature in invoice number as well. Could anyone help me how to solve that by adding a few lines of code in which file?

Also wanted to ask - from other reasons, but relating mainly to this, so maybe it's not a big problem for do not creating another thread for this question - in which file, on which lines does Hikashop generate the Order number? Maybe the first question's answer is the same for the this...

Thanks for your help in advance,
PePe

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 1 month ago #173665

Hi,


Try to change the code:

if(preg_match_all('#\{([a-z_0-9]+)\}#i',$format,$matches)){
			foreach($matches[1] as $match){
				if(isset($data->$match)){
					$format = str_replace('{'.$match.'}',$data->$match,$format);
				}else{
					$format = str_replace('{'.$match.'}','',$format);
				}
			}
		}
to:
if(preg_match_all('#\{([a-z_0-9]+) *(?:size=(?:"|\')(.*)(?:"|\'))? *\}#i',$format,$matches)){
			foreach($matches[1] as $k => $match){
				if(isset($data->$match)){
					$copy = $data->$match;
					if(!empty($matches[2][$k])){
						$copy = sprintf('%0'.$matches[2][$k].'d', $copy);
					}
					$format = str_replace('{'.$match.'}',$copy,$format);
				}else{
					$format = str_replace('{'.$match.'}','',$format);
				}
			}
		}
in the file administrator/components/com_hikashop/helpers/helper.php and that should allow you to use the size parameter for any field of the order, not just the id.

The following user(s) said Thank You: pepecortez

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

  • Posts: 171
  • Thank you received: 9
10 years 1 month ago #175483

nicolas wrote: Hi,


Try to change the code:

if(preg_match_all('#\{([a-z_0-9]+)\}#i',$format,$matches)){
			foreach($matches[1] as $match){
				if(isset($data->$match)){
					$format = str_replace('{'.$match.'}',$data->$match,$format);
				}else{
					$format = str_replace('{'.$match.'}','',$format);
				}
			}
		}
to:
if(preg_match_all('#\{([a-z_0-9]+) *(?:size=(?:"|\')(.*)(?:"|\'))? *\}#i',$format,$matches)){
			foreach($matches[1] as $k => $match){
				if(isset($data->$match)){
					$copy = $data->$match;
					if(!empty($matches[2][$k])){
						$copy = sprintf('%0'.$matches[2][$k].'d', $copy);
					}
					$format = str_replace('{'.$match.'}',$copy,$format);
				}else{
					$format = str_replace('{'.$match.'}','',$format);
				}
			}
		}
in the file administrator/components/com_hikashop/helpers/helper.php and that should allow you to use the size parameter for any field of the order, not just the id.


Tried it out, but unfortunately it's not working...

"order_id size=5" text is taken to the invoice id, not the id.

Order id format is set to: HUPT/MR-{id size="5"}/{date format="d/m/Y"}
Invoice id format is set to: HUPT/MR-{order_id size="5"}/{date format="d/m/Y"}

Any ideas?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 1 month ago #175509

Hi,

Instead of the code:

if(preg_match_all('#\{([a-z_0-9]+)\}#i',$format,$matches)){
			foreach($matches[1] as $match){
				if(isset($data->$match)){
					$format = str_replace('{'.$match.'}',$data->$match,$format);
				}else{
					$format = str_replace('{'.$match.'}','',$format);
				}
			}
		}
please try with the code:
if(preg_match_all('#\{([a-z_0-9]+) *(?:size=(?:"|\')(.*)(?:"|\'))? *\}#i',$format,$matches)){
			foreach($matches[1] as $k => $match){
				$copy = @$data->$match;
				if(!empty($matches[2][$k])){
					$copy = sprintf('%0'.$matches[2][$k].'d', $copy);
				}
				$format = str_replace($matches[0][$k],$copy,$format);
			}
		}
in the file administrator/components/com_hikashop/helpers/helper.php and that should work better.

The following user(s) said Thank You: pepecortez

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

  • Posts: 171
  • Thank you received: 9
10 years 1 month ago #175614

Works like a charm!
Thanks again!

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

  • Posts: 1
  • Thank you received: 0
9 years 3 months ago #212035

I have 2.5.5 version, and the code I don't find in the file.
Is there any trick for having id-size?
Thanks

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 3 months ago #212055

Hi,

There is no HikaShop 2.5.5 yet. The latest version of HikaShop is 2.5.0.
If you have the latest version of HikaShop, that modification is already in there so you can directly use the size attribute with the order_id tag, without changing any code.

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

Time to create page: 0.074 seconds
Powered by Kunena Forum