Shop By Price

I would like to have a mod whereby a customer can view products by price. I know they can be sorted by price but what I’d like to have is a side box.



$10.00 - $100.00

$101.00 - $200.00

$201.00 - $300.00



And so on

Ive been thinking about this too…



It would be easy to make a “hack” for this, but to do it properly would require more work.



For instance 0 - £10 with an ugly url would be :

[URL=“http://www.car-audio-accessories.co.uk/index.html?target=products&mode=search&type=extended&match=any&price_from=0&price_to=10&button=Search”]http://www.car-audio-accessories.co.uk/index.html?target=products&mode=search&type=extended&match=any&price_from=0&price_to=10&button=Search[/URL]



£10 to £50 would be :

[URL=“http://www.car-audio-accessories.co.uk/index.html?target=products&mode=search&type=extended&match=any&price_from=10&price_to=50&button=Search”]http://www.car-audio-accessories.co.uk/index.html?target=products&mode=search&type=extended&match=any&price_from=10&price_to=50&button=Search[/URL]



Etc, however I realise it would be much better if it only displayed price ranges which are available etc.

It would be perfect for a jewelry site I’m working on. I’ll request a quote and see where it takes us.

Here is a start for that mod if someone has time to play with it. Then add an include in main.tpl.


```php

{capture name=menu}






$1-$100






$100-$250






$250-$500






$500-$1000






$1000-$10000


{/capture}
{include file="common_templates/sidebox.tpl" title=$lang.shop_by_price content=$smarty.capture.sidebox icon="sidebox_icon_help.gif"}
```

Hello to all,

this is my proposition:


  1. Go to admin panel->Languages and create a variable price_ranges with a value like “Price ranges” or something like that.
  2. Go at the end of /init.php and add the following:


$smarty->assign('price_ranges',
array(
"1"=>"100",
"101"=>"200",
"201"=>"300",
"301"=>"400",
"401"=>"1000"
));




You can of course change these values to whatever ranges fit your needs.



3. Create a file called price_ranges.tpl in /skins/YOURSKIN/customer/side_boxes with the following contents:


{capture name="sidebox"}

{foreach from=$price_ranges key='price_from' item='price_to'}
{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}


{/foreach}

{/capture}
{include file="common_templates/sidebox.tpl" title=$lang.price_ranges content=$smarty.capture.sidebox}




4. On /skins/YOURSKIN/customer/main.tpl, after {[/ADDONS_DATA]} (around line 27) add the following line



{include file=“side_boxes/price_ranges.tpl”}





I hope this seems helpful,

Alexandros

Alexandros. This works perfectly. Just what I wanted and I am sure this will be of service to many. IMO this kind of help is what makes CS-Cart the best. You can see it at work at www.signaturediamondgems.com. Thank you.

Thank Alexandros



Nice work

Works perfect.

Thank you.

But maybe you can tell us how to rewright by price urls?


[quote name=‘abinop’]Hello to all,

this is my proposition:


  1. Go to admin panel->Languages and create a variable price_ranges with a value like “Price ranges” or something like that.
  2. Go at the end of /init.php and add the following:


$smarty->assign('price_ranges',
array(
"1"=>"100",
"101"=>"200",
"201"=>"300",
"301"=>"400",
"401"=>"1000"
));




You can of course change these values to whatever ranges fit your needs.



3. Create a file called price_ranges.tpl in /skins/YOURSKIN/customer/side_boxes with the following contents:


{capture name="sidebox"}

{foreach from=$price_ranges key='price_from' item='price_to'}
{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}


{/foreach}

{/capture}
{include file="common_templates/sidebox.tpl" title=$lang.price_ranges content=$smarty.capture.sidebox}




4. On /skins/YOURSKIN/customer/main.tpl, after {[/ADDONS_DATA]} (around line 27) add the following line



{include file=“side_boxes/price_ranges.tpl”}





I hope this seems helpful,

Alexandros[/quote]

[QUOTE]But maybe you can tell us how to rewright by price urls?[/QUOTE]



Sure,

add line


RewriteRule ^([^/]*/)?search-from-([0-9]+)-to-([0-9]+) $1index.php?target=products&mode=search&type=extended&match=any&price_from=$2&price_to=$3 [L]



to your .htaccess



and change


{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}



on file /YOURSKIN/customer/side_boxes/price_ranges.tpl (line 5)





to


{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}





Tell me if it works ok for you.



Alexandros

Thank you, works fine.

thank abinop, i have two question



my first question is:



how can we show the price list as classified by categories?



example;



when we select $100-$150 it must show



x category (5) y category (1) z category (11) etc.



and my another question:



how can we show price list as “below $100” and “above $1000”



thanks again :smiley:

Last Ninja, have you found a solution? Also, what does rewriting by price URL mean?



Lastly, can anyone tell me how to put the shop by price ranges in a drop down menu? Thanks!

Has anyone figured how to put the price ranges in a drop down menu? But more importantly…does any expert professional cscart person know how to set the language to “less than $50” instead of “$1 - $50” :confused: :confused:

Could this problem not also be sorted by creating a new category “By Price” with the required subcategories.



The item can then be put into the correct additional category.



Not ideal since if the price changed the category would have to be changed also. But it might suit for many.

[quote name=‘abinop’]Sure,

add line


RewriteRule ^([^/]*/)?search-from-([0-9]+)-to-([0-9]+) $1index.php?target=products&mode=search&type=extended&match=any&price_from=$2&price_to=$3 [L]



to your .htaccess



and change


{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}



on file /YOURSKIN/customer/side_boxes/price_ranges.tpl (line 5)





to


{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}



[/QUOTE]



For all who want this code for 135



do all the steps as above but instead of


RewriteRule ^([^/]*/)?search-from-([0-9]+)-to-([0-9]+) $1index.php?target=products&mode=search&type=extended&match=any&price_from=$2&price_to=$3 [L]



use


RewriteRule ^([^/]*/)?search-from-([0-9]+)-to-([0-9]+)$ $1index.php?target=products&mode=search&type=extended&match=any&price_from=$2&price_to=$3 [L]




:wink:

You can sort your results from lower to higher:



Change:


{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}



to:


{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}



This is more in line according some consumer groups rules (and some local laws - especialy in Europe), wanting prices sorted from lowest to highest…







Lee Li Pop

i came across this post and wanted to add this feature but where is the file?



/init.php



thanks

In your root directory for your store

my ftp program didnt go to the root, but i got it in the file manager



thanks





*awsome!!!

[quote name=‘abinop’]Hello to all,

this is my proposition:


  1. Go to admin panel->Languages and create a variable price_ranges with a value like “Price ranges” or something like that.
  2. Go at the end of /init.php and add the following:


$smarty->assign('price_ranges',
array(
"1"=>"100",
"101"=>"200",
"201"=>"300",
"301"=>"400",
"401"=>"1000"
));




You can of course change these values to whatever ranges fit your needs.



3. Create a file called price_ranges.tpl in /skins/YOURSKIN/customer/side_boxes with the following contents:


{capture name="sidebox"}

{foreach from=$price_ranges key='price_from' item='price_to'}
{$currencies.$secondary_currency.symbol}{$price_from}-{$currencies.$secondary_currency.symbol}{$price_to}


{/foreach}

{/capture}
{include file="common_templates/sidebox.tpl" title=$lang.price_ranges content=$smarty.capture.sidebox}




4. On /skins/YOURSKIN/customer/main.tpl, after {[/ADDONS_DATA]} (around line 27) add the following line



{include file=“side_boxes/price_ranges.tpl”}





I hope this seems helpful,

Alexandros[/QUOTE]

Hi,



instead of sidebox with price ranges I get>



Warning: Smarty error: unable to read resource: “side_boxes/price.tpl” in /hermes/bosweb/web046/b465/sl.pianofo/forteshop.cz/classes/templater/Smarty.class.php on line 1095



Pls, help me