X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Creating Price Range Links (https://forum.x-cart.com/showthread.php?t=56313)

nickff 11-01-2010 10:47 AM

Creating Price Range Links
 
Hi All,

I've created a set of "price range links" that use static search URL's to display all products between 0-$200, $201-$500, etc.

The links function perfectly, but I'm trying to get them to have an 'active' class applied to them when you are on the appropriate page. I've attempted to access the 'price_min' and 'price_max' elements of the 'search_prefilled' array, but with no luck.

Here's my code:

HTML Code:


{foreach from=$search_prefilled item=s}
    {assign var='minimum_price' value=$s.price_min}
    {assign var='maximum_price' value=$s.price_max}
{/foreach}

<!-- Search by Price -->
<ul id="norm">
    <li {if $main eq 'search' && $maximum_price eq 199.99}class="active"{/if}>
        <a href="search.php?mode=search&including=all&by_title=off&by_descr=off&by_sku=off&search_in_subcategories=on&price_min=0.00&price_max=199.99"><$200</a>
    </li>
    <li {if $main eq 'search' && $maximum_price eq 500.99}class="active"{/if}>
        <a href="search.php?mode=search&including=all&by_title=off&by_descr=off&by_sku=off&search_in_subcategories=on&price_min=200.00&price_max=500.99">$200-$500</a>
    </li>
    <li {if $main eq 'search' && $maximum_price eq 1000.99}class="active"{/if}>
        <a href="search.php?mode=search&including=all&by_title=off&by_descr=off&by_sku=off&search_in_subcategories=on&price_min=501.00&price_max=1000.99">$501-$1000</a>
    </li>
    <li {if $main eq 'search' && $maximum_price eq 1000000.00}class="active"{/if}>
        <a href="search.php?mode=search&including=all&by_title=off&by_descr=off&by_sku=off&search_in_subcategories=on&price_min=1001.00&price_max=1000000.00">>$1000</a>
    </li>
</ul>


If anyone has any ideas on how to get active classes to correctly appear for this type of link let me know. Thanks!

Snowrev 11-02-2010 07:52 AM

Re: Creating Price Range Links
 
What files should this code be added to? I want the price range to show up on the left side of light and lucid 3 column theme.

Great idea and thanks for the code.

nickff 11-02-2010 08:29 AM

Re: Creating Price Range Links
 
Hi Snowrev,

Not sure what version you're using (might want to put it in your signature), but for 4.4 you'll probably want to put the code somewhere in common_files/customer/left_bar.tpl

I tend to use the 2-column layout so I'm not 100% on that. Try using the webmaster mode under tools to find the .tpl file that you are editing.

Snowrev 11-02-2010 08:39 AM

Re: Creating Price Range Links
 
Thank you.. I will try now and put the code there. Will this display all products on the site based on the price range?

nickff 11-02-2010 08:46 AM

Re: Creating Price Range Links
 
Yes,

It will display all products across the site within those ranges.

You would need to add "&categoryid=2" to the query string in order to search a specific category at that price range, where "2" is the category you are wanting to search through.

Snowrev 11-02-2010 08:49 AM

Re: Creating Price Range Links
 
I tried the code and think its a great idea but I will need to apply it as a filter option for particular products for this site.. Let me know if you find out how to do it.. I tested the code but didnt get search results, does it automatically grab the item price? or do you have to insert the item price someone on the products detail page?

nickff 11-02-2010 08:50 AM

Re: Creating Price Range Links
 
Make sure you don't already have some filter options set in your search boxes. Clear them all out then try the links (x-cart remembers past search filters by default).

mudebate 11-28-2010 09:36 AM

Re: Creating Price Range Links
 
Quote:

search.php?mode=search&including=all&by_title=off& by_descr=off&by_sku=off&search_in_subcategories=on &price_min=0.00&price_max=199.99"><$200</a>



Is there a way to add a filter by manufacturer to the search string that anyone is aware of? I tried just adding &manufacturerid but it did not do the trick.

Drill by price works great though - Thanks for posting the code!


All times are GMT -8. The time now is 07:41 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.