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

Related Products: Don't show link if out of stock?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-04-2006, 04:30 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #2  
Old 01-04-2006, 05:32 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

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...
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 01-04-2006, 11:01 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default

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.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #4  
Old 01-04-2006, 11:08 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

{if $product.avail gt 0}
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 01-04-2006, 04:37 PM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default

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.

I opened a ticket with Xcart.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #6  
Old 01-06-2006, 06:12 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default

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.

__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #7  
Old 01-11-2006, 10:14 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default

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); ?>
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #8  
Old 06-18-2008, 11:05 AM
  tqualizerman's Avatar 
tqualizerman tqualizerman is offline
 

X-Adept
  
Join Date: Jun 2008
Posts: 392
 

Default 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?
__________________
- www.nerdseven.com - Gadgets & Gizmos from Out of This World
- Sound Sensitive T-Shirts That Flash to the Beat of Music (http://www.tqualizer.com)


X-Cart Version 4.1.10
Reply With Quote
  #9  
Old 06-19-2008, 01:28 PM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 02:22 AM.

   

 
X-Cart forums © 2001-2020