Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Show only items in stock button

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 08-12-2006, 01:49 AM
 
hansmoen hansmoen is offline
 

Member
  
Join Date: Dec 2005
Posts: 12
 

Default Show only items in stock button

Howdy,

Based on feedback on our store I made this quick and simple mod to enable people to view only items in stock.

http://www.pchealth.ie to see it in action (this is a live store)

This is how I did it in X-Cart 4.0.18:

In include/search.php below
Code:
if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }

add
Code:
# To enable showing only products in stock. http://forum.x-cart.com/viewtopic.php?p=149643#149643 $show_only_products_in_stock = ($_GET['avail_only'] == 1 || $_POST['avail_only'] == 1) ? true : false;

locate
Code:
$smarty->assign("navigation_script","search.php?mode=search");
change to
Code:
$smarty->assign("navigation_script","search.php?mode=search&avail_only=$show_only_products_in_stock");

in /products.php

add (last line before '?>')
Code:
# Assign the "Show Only Products In Stock" $smarty->assign("avail_only", $show_only_products_in_stock);

locate
Code:
$smarty->assign("navigation_script","home.php?cat=$cat&sort=$sort&sort_direction=$sort_direction");
change to
Code:
$smarty->assign("navigation_script","home.php?cat=$cat&sort=$sort&sort_direction=$sort_direction&avail_only=$show_only_products_in_stock");


in /search.php
add (last line before 'func_display("customer/home.tpl",$smarty);')
Code:
# Assign the "Show Only Products In Stock" $smarty->assign("avail_only", $show_only_products_in_stock);


create a file /skin1/customer/main/show_instock.tpl and add
Code:
Show: {if $avail_only eq 1}{else}{/if}All products{if $avail_only eq 1}{else}{/if} {if $avail_only eq 0}{else}{/if}Only in stock{if $avail_only eq 0}{else}{/if}


in /skin1/customer/main/subcategories.tpl
/skin1/customer/main/search_result.tpl
(if you have the Manufacturers modules activated also
/skin1/modules/Manufacturers/customer_manufacturer_products.tpl)

add
Code:
{include file="customer/customized/show_instock.tpl" url="home.php?cat=`$cat`&sort=`$search_prefilled.sort_field`&sort_direction=`$search_prefilled.sort_direction`"}
locate
Code:
{include file="main/search_sort_by.tpl" sort_fields=$sort_fields selected=$search_prefilled.sort_field direction=$search_prefilled.sort_direction url="###home.php or search.php####&"}
in the "url=xxxx" add 'avail_only=`$avail_only`&' (withouth the quotes)

if you have the Manufacturers module activated also do this:

in /modules/Manufacturers/customer_manufacturers_list.php
locate
Code:
$smarty->assign("navigation_script","manufacturers.php?manufacturerid=".$manufacturerid."&sort=".$sort."&sort_direction=".$sort_direction);
change to
Code:
$smarty->assign("navigation_script","manufacturers.php?manufacturerid=".$manufacturerid."&sort=".$sort."&sort_direction=".$sort_direction."&avail_only=".$show_only_products_in_stock);
add
Code:
# Assign the "Show Only Products In Stock" $smarty->assign("avail_only", $show_only_products_in_stock);


And that should be about it...
I know this isn't the best of recipes, but I hope someone might find it useful, at least for inspiration.

Hasse
__________________
Hasse
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:33 AM.

   

 
X-Cart forums © 2001-2020