Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

(tiny tip) Allowing "$" in Advanced Search price range


squeekit

Recommended Posts

Posted

> I searched the forum but didn't find anything on this (it's gotta be here somewhere) <

 

I didn't want to snag customers on the Advanced Search "Price From:" and "Price To:" fields not recognizing an entry if proceeded with the USD dollar sign - nor did i want to bother customers with instructions stating that they should not enter "$" in these feilds...

 

the only option left > fix it...

 

My solution was to simply change advanced_search_result.php (starting at line 15):

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 $error = false;

by inserting code so that it now reads:

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 if ( isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom']))
   $HTTP_GET_VARS['pfrom'] = ltrim($HTTP_GET_VARS['pfrom'],"\$");
 if ( isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto']))
   $HTTP_GET_VARS['pto'] = ltrim($HTTP_GET_VARS['pto'],"\$");

 $error = false;

The result is...

that essentially it makes no difference whether or not a customer enters "22" or "$22" into the Advanced Search "Price From:" or "Price To:" feilds

:)

 

-----------------------------------------------------------------------------------

 

[tiny todo list]

now, for the fun of it, to round input decimal places to two for these fields - so if a customer enters "$22.89357645636" then performs a search, then hits the back button they will only see "22.89" in that feild ;)

Posted

well, while I'm on the advanced_search_result.php (within the OSC root):

 

I also didn't like ugly errors tossed up if any customers happened to get silly with the From/To dates they entered - like if they tried being 'smart' and attempted to enter a From Date of 01/01/1900 in an attempt to catch all in the store from its begining (logic > "surely, if i enter '1900' i'll retrieve all from the time the store opened")

 

Sooo...

 

My quickFix (still on advanced_search_result.php):

Directly above the line...

	if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) {

I added...

	if ($dfrom_array[0] < 1970) {
	$dfrom_array[0] = 1970;
}
if ($dto_array[0] < 1970) {
	$dto_array[0] = 1970;
}

being that the first day of January 1970 is the absolute that dates are scaled to --- yeah I know - just a quick fix - but sure is better than the ugly code error it use to toss if someone entered a date previous to 1970 - and well > most important > its totally functional...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...