Searching by Price

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

Re: [WEVOLUTIONS] Searching by Price

By Perchpole - November 12, 2008

My advice would be to avoid using any non-alpha-numeric characters. You can then "render" the "$" in HTML next to your CMSB output...

The price of this property is $<?php echo $record['price'] ?>

...sort of thing.

That way your search need only consider real numbers - not numbers and symbols. I've produced a 100+ product catalogue using this method and it works a treat.

:0)

Perchpole

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

By wevolutions - November 14, 2008

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