X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Show only items in stock button (https://forum.x-cart.com/showthread.php?t=24051)

hansmoen 08-12-2006 01:49 AM

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


All times are GMT -8. The time now is 02:17 AM.

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