Searching by Price

5 posts by 4 authors in: Forums > CMS Builder
Last Post: November 14, 2008   (RSS)

I am trying price_min and price_max to search my price listings but it is not working.

Note: I have a "$" in my price on the listings eg. $75,000.00 so will this cause the search to not function properly?

And if this is the case, what can be done to modify a price search with alpha numeric values?

Re: [WEVOLUTIONS] Searching by Price

By Kenny - November 12, 2008 - edited: November 12, 2008

The values need to be all numeric, like this:

<option value="100000">$100,000</option>

You can definitely have a $ in your listings, but I would put in your html code where it shows up automatically instead of putting it in as a value.

Automatically place dollar signs, commas, and decimals with:

$<?php echo number_format($record['price'] ,2) ?>


The ",2" tells it to give two decimal places

The "number_format" tells it to treat it like a number to include comma separators.

Notice the "$" before the echo statement - that's just embedded into the code so it shows up automatically for every price.

On the backend, we just allow the user to enter in numbers.

So they would enter in 3456 (or 3456.00)

And what would be displayed is $3,456.00

If you plan on sorting by numbers, then use this:

'orderBy' => 'price+0 DESC',


That help?

Kenny

Re: [sagentic] Searching by Price

Thank you guys for that information. I will have to do some adjustments to my prices on the site.

Can you confirm whether a comma in the price will affect the search from working? Eg. 75,000

Re: [WEVOLUTIONS] Searching by Price

By Dave - November 14, 2008

Hi WEVOLUTIONS,

Yes, it will. You need all numeric values in the database. You can have the automatically formatted to display like that on the website though.
Dave Edis - Senior Developer
interactivetools.com