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)
-   -   Related Products: Don't show link if out of stock? (https://forum.x-cart.com/showthread.php?t=19020)

JWait 01-04-2006 04:30 AM

Related Products: Don't show link if out of stock?
 
I have discovered that a related product link is still displayed even if the related product is out of stock, regardless of whether the 'Disable products which are out of stock' box is checked. If the customer clicks one of these links they get an error if the product they are trying to find is out of stock / disabled. I think there needs to be a 'product_available = Y' check somewhere in the related_products.tpl before displaying the link but don't know the correct syntax.

Basically, what I want to do is..
If product is in stock display link or else do nothing.

Any help here would be appreciated.

balinor 01-04-2006 05:32 AM

Strange....I would have assumed X-Cart would have set it up to disable out of stock related and recommended products. Might want to open a ticket with them to address this...

JWait 01-04-2006 11:01 AM

If the related product is 'Available for Sale' and the 'Quantity in stock' = 0 the link is there on the Product page. If the related product is 'Disabled' the Related Products link disappears. I could just set all products with 'Quantity in stock = 0' to 'Disabled', but then I would have to remember to enable them again once stock is replenished.

Isn't there some query to check if the quantity in stock is greater than 0 so that I could add an 'if' statement to the related_products.tpl to determine whether to display the link or not? What I am looking for is the syntax of this query.

balinor 01-04-2006 11:08 AM

{if $product.avail gt 0}

JWait 01-04-2006 04:37 PM

Thank you but I think that will just check to see if the original product >0, not the related product. Look at the related_products.tpl and we see it loops, looking at '$product_links[cat_num].productid' (of which, $product_links seems to be assigned by related_products.php).

Code:

{* $Id: related_products.tpl,v 1.10.2.1 2004/10/07 10:52:42 max Exp $ *}
{if $product_links ne ""}
{capture name=dialog}
<TABLE border="0" cellspacing="5">
{section name=cat_num loop=$product_links}
<TR class="ItemsList">
<TD width="1%">{$product_links.productid}</TD>
<TD width="99%">
{* SAFETYNET DSEFU MOD *}
{if $enable_seo_links == "Y"}
<A href="{seo_link prod_name=$product_links[cat_num].product prod_id=$product_links[cat_num].productid}"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}>
{$product_links[cat_num].product}
</A>
{else}
<A href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}>
{ $product_links[cat_num].product}
</A>
{/if}
{* END SAFETYNET *}
</TD>
</TR>
{/section}
</TABLE>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"}
{/if}

I think what I need is something like {if $product_links[cat_num].product.avail gt 0} but I know that syntax is not correct.... {if $product_links.avail gt 0} doesn't work either. :cry:

I opened a ticket with Xcart.

JWait 01-06-2006 06:12 AM

X-cart made a new related_products.php file that doesn't show products that are out of stock (provided 'Disable products which are out of stock' is checked). I assume this available to anyone in the files section of the Help Desk, and it doesn't look like they charged me any points either.

:D

JWait 01-11-2006 10:14 AM

Here is what X-cart sent me, and it seems to fix the problem... a new related_products.php. I assumed they would have the file available to everyone, but apparently not.

Code:

<?php
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart                                                                      |
| Copyright (c) 2001-2005 Ruslan R. Fazliev <rrf@rrf.ru>                      |
| All rights reserved.                                                        |
+-----------------------------------------------------------------------------+
| PLEASE READ  THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE  |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php                    |
|                                                                            |
| THIS  AGREEMENT  EXPRESSES  THE  TERMS  AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE  PROGRAM  AND  ASSOCIATED  DOCUMENTATION  THAT  RUSLAN  R. |
| FAZLIEV (hereinafter  referred to as "THE AUTHOR") IS FURNISHING  OR MAKING |
| AVAILABLE TO YOU WITH  THIS  AGREEMENT  (COLLECTIVELY,  THE  "SOFTWARE").  |
| PLEASE  REVIEW  THE  TERMS  AND  CONDITIONS  OF  THIS  LICENSE AGREEMENT |
| CAREFULLY  BEFORE  INSTALLING  OR  USING  THE  SOFTWARE.  BY INSTALLING, |
| COPYING  OR  OTHERWISE  USING  THE  SOFTWARE,  YOU  AND  YOUR  COMPANY |
| (COLLECTIVELY,  "YOU")  ARE  ACCEPTING  AND AGREEING  TO  THE TERMS OF THIS |
| LICENSE  AGREEMENT.  IF  YOU    ARE  NOT  WILLING  TO  BE  BOUND BY THIS |
| AGREEMENT, DO  NOT INSTALL OR USE THE SOFTWARE.  VARIOUS  COPYRIGHTS  AND |
| OTHER  INTELLECTUAL  PROPERTY  RIGHTS    PROTECT  THE  SOFTWARE.  THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES  YOU  LIMITED  RIGHTS  TO  USE |
| THE  SOFTWARE  AND  NOT  AN  AGREEMENT  FOR SALE OR FOR  TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT.      |
|                                                                            |
| The Initial Developer of the Original Code is Ruslan R. Fazliev            |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2005          |
| Ruslan R. Fazliev. All Rights Reserved.                                    |
+-----------------------------------------------------------------------------+
\*****************************************************************************/

#
# $Id: related_products.php,v 1.16.2.5 2006/01/05 11:37:30 max Exp $
#
# This Module forms list of upsailing products
#

if ( !defined('XCART_SESSION_START') ) { header("Location: ../../"); die("Access denied"); }

$avail_condition = "";
if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y") {
        $avail_condition = "AND $sql_tbl[products].avail > 0";
}

$product_links = func_query("SELECT DISTINCT $sql_tbl[products].productid, $sql_tbl[products].productcode, MIN($sql_tbl[pricing].price) AS price, IF ($sql_tbl[products_lng].product IS NOT NULL AND $sql_tbl[products_lng].product != '', $sql_tbl[products_lng].product, $sql_tbl[products].product) AS product FROM $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[product_links], $sql_tbl[products_categories], $sql_tbl[categories] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products_lng].productid = $sql_tbl[products].productid AND $sql_tbl[products_lng].code='$store_language' WHERE $sql_tbl[products].productid=$sql_tbl[product_links].productid2 AND $sql_tbl[product_links].productid1='$productid' AND $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0 AND ($sql_tbl[pricing].membership='".addslashes($membership)."' OR $sql_tbl[pricing].membership='') AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products_categories].productid = $sql_tbl[products].productid AND $sql_tbl[products_categories].categoryid = $sql_tbl[categories].categoryid AND $sql_tbl[categories].avail = 'Y' AND $sql_tbl[products].productid != '$productid' $avail_condition GROUP BY $sql_tbl[products].productid ORDER BY $sql_tbl[product_links].orderby, product");


$smarty->assign("product_links",$product_links);
?>


tqualizerman 06-18-2008 11:05 AM

Re: Related Products: Don't show link if out of stock?
 
Can anyone advise how you might be able to show whether a product in 'related products' is in or out of stock?

JWait 06-19-2008 01:28 PM

Re: Related Products: Don't show link if out of stock?
 
Using the 4.1.x versions of x-cart, related products will not be shown if they are out of stock by default. To show the out of stock products it is necessary to leave the 'Disable products which are out of stock' option unchecked in the general settings/appearance options of the admin section.


All times are GMT -8. The time now is 04:48 PM.

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