Zencart Price Filter Plugin

Source: Internet
Author: User

1. First, create a new file includes\modules\sideboxes\price_range.php

<?PHPfunctionZen_count_products_in_price ($pfrom,$pto){    Global $db; if((int)$pfrom>= 1) {            $products _query= "Select COUNT (*) as Total from" . Table_products. "P,". Table_products_to_categories. "p2c where p.products_id = p2c.products_id and P.products_price >" .$pfrom; if($pto! = ' ∞ ')        {            $products _query. = "and P.products_price <=".$pto; }        //Echo $products _query. ' <br/> ';        $products=$db->execute ($products _query); $products _count=$products->fields[' Total ']; }    return(int)$products _count;}$price _array=Array();$price _array[] =Array(' Pfrom ' =>1, ' PTO ' =>300, ' counts ' =>zen_count_products_in_price (1,300));$price _array[] =Array(' Pfrom ' =>301, ' PTO ' =>500, ' counts ' =>zen_count_products_in_price (301,500));$price _array[] =Array(' Pfrom ' =>501, ' PTO ' =>1000, ' counts ' =>zen_count_products_in_price (501,1000));$price _array[] =Array(' Pfrom ' =>1001, ' PTO ' =>2000, ' counts ' =>zen_count_products_in_price (1001,2000));$price _array[] =Array(' Pfrom ' =>2001, ' PTO ' =>3000, ' counts ' =>zen_count_products_in_price (2001,3000));$price _array[] =Array(' Pfrom ' =>3001, ' PTO ' =>4000, ' counts ' =>zen_count_products_in_price (3001,4000));$price _array[] =Array(' Pfrom ' =>4001, ' PTO ' =>5000, ' counts ' =>zen_count_products_in_price (4001,5000));$price _array[] =Array(' Pfrom ' =>5001, ' pto ' = ' ∞ ', ' Counts ' =>zen_count_products_in_price (5001, ' all ')));$content= ' ';$This _cpath=$cPath;$content. = ' <div id= '.Str_replace(‘_‘, ‘-‘,$box _id. ' Content '). ' "class=" Sideboxcontent ">". "\ n";$content. = ' <ul> ';$price _array_count=Count($price _array); for($RR= 0;$RR<$price _array_count;$RR++){    $content. = ' <li><a '; if($price _array[$RR[' Pfrom ']==$_get[' Pfrom '] and$price _array[$RR[' PTO ']==$_get[' PTO '])    {        $content. = ' class= ' pricecurrent "'; }    $content. = ' href= ' index.php?main_page=advanced_search_result&search_in_description=1 '; if($_get[' categories_id '])    {        Echo' &categories_id= '.$This _cpath; }    $content. = ' &inc_subcat=1&pfrom= '.$price _array[$RR[' Pfrom ']. ' &pto= '.$price _array[$RR[' PTO ']. ' "rel=" nofollow ">".$price _array[$RR[' Pfrom ']; if(!Empty($price _array[$RR[' PTO ']))    {        $content. = '-'.$price _array[$RR[' PTO '].$GLOBALS[' Currencies ']->currencies[$_session[' Currency '] [' Symbol_left ']; }Else{        $content. = ' &nbsp; Up to ... '; }    $content. = ' </a><span> ('.$price _array[$RR[' Counts ']. ') </span></li> ';}$content. = ' </ul> ';$content. = ' </div> ';$title= ' Price Range ';require($template->get_template_dir ($column _box_default, Dir_ws_template,$current _page_base, ' common '). ‘/‘ .$column _box_default);?>

2. Beautify the foreground display with CSS code

#pricerange a{Padding-left:15px;Line-height:27px;font-size:12px;Color:#666;background:URL (".. /images/pricea.gif ") no-repeat scroll 0 2px Transparent;}#pricerange a:hover, #pricerange a.pricecurrent{Color:#0075e2;text-decoration:None;background:URL (".. /images/priceahover.gif ") no-repeat scroll 0 2px Transparent;}#pricerange ul, #pricerange ul Li{padding:0;margin:0;}#pricerange ul Li{Border-bottom:1px dashed #ccc;Line-height:23px;List-style-type:None;text-indent:12px;font-size:12px;}#pricerange ul Li Span{Color:#999999;Display:inline;Font:10px Arial;Padding-left:2px;}

Attached: CSS style picture

3. Background to open the border price filter plug-in.

Zencart Price Filter Plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.