<?php
//get shop page's title
$t = $site->pageTitle($s['shop_page']);
$seo_pageTitle = seo_str($t);
//add meta tags to the page if showing a sub category
$array['page_title'] = 'Search shop';
$array['keywords'] .= ',search,products,shop,items,find';
//form
$mainhtml .= '<h1>Search shop</h1>';
$mainhtml .= '<p id="shopCrumbs"><a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'">'.$t.'</a> &gt; <strong>Search</strong></p>';
$mainhtml .= '<form id="search" name="search" method="post" action="">
<p>Please type in name of a product, in part or whole, to search.</p>
<input type="text" name="query" id="query" value="'.$_POST['query'].'" size="32" />&nbsp;<input type="submit" id="s" name="s" value="Search" class="button" /></form>';
//results
if(!empty($_POST['query']))
{
$post = $form->clean_fields($_POST);
$mainhtml .= '<hr /><h2>Search results</h2>';
$query = $mysql->query("ID,name,price,sale_price,thumb_image,url_key" ,"fs_shop_products", "hide = 'n' AND (`name` LIKE '%{$post['query']}%' OR `description` LIKE '%{$post['query']}%') AND cat > 0 LIMIT 50");
if($mysql->num_rows($query) == 0)
{
$mainhtml .= '<p>Your search - <strong>'.$_POST['query'].'</strong> - did not match any products.</p><p>Suggestions:</p><ul><li>Try different keywords.</li><li>Make sure all words are spelled correctly.</li><li>Try more general keywords.</li></ul>';
}
else
{
$mainhtml .= '<div id="prodlist">';
$size = $site->shop_settings('catimage_height,catimage_width');
while($data = $mysql->get_array($query))
{
$price = $site->currency_symbol($data['price']);
$shortName = (strlen($data['name']) > 42) ? substr($data['name'], 0, 42).'...' : $data['name'];
if($data['sale_price'] > 0){$price = 'WAS <span class="sale">'.$site->currency_symbol($data['price']).'</span><br /><strong>NOW '.$site->currency_symbol($data['sale_price']).'</strong>';}
$outOfStock = (!$site->in_stock($data['ID'])) ? '<br /><strong>Out of stock</strong>' : '';
$mainhtml .= '<table border="0" cellspacing="0" cellpadding="0" width="'.$size['catimage_width'].'">
<tr>
<th><a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'/'.$data['url_key'].'" target="_blank"><img src="/inc/shop/images/clear.gif" alt="'.$data['name'].'" width="'.$size['catimage_width'].'" height="'.$size['catimage_height'].'" border="0" title="'.$data['name'].'" style="background-image: url(/inc/shop/images/'.$data['thumb_image'].');" /></a></th>
</tr>
<tr>
<td><a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'/'.$data['url_key'].'" title="'.$data['name'].'" target="_blank">'.$shortName.'</a> '.$price.$outOfStock.'</td>
</tr>
</table>';
}
$mainhtml .= '</div>';
$mainhtml = stripslashes($mainhtml);
}
}
//include this add-ons's overwrite css file from the template being used, if there is one
$t = settings('template');
if(file_exists('templates/'.$t['template'].'/addons/shop.css'))
{
$mainhtml = str_replace("</head>", '<link rel="stylesheet" type="text/css" href="/templates/'.$t['template'].'/addons/shop.css" /></head>', $mainhtml);
}
else
{
$mainhtml = str_replace("</head>", '<link rel="stylesheet" type="text/css" href="//www.freesites.com.au/addons/shop.css" /></head>', $mainhtml);
}
//end
?>