Add prices to related items (v. 2.8 - 2.9)
If you'd like to add a price range to the related items that show under each product, you can use the following modification:
Version 2.9x:
-
Open the the products_variables.php file in the /enc/ folder.
-
Change the following code, around line 860:
$relquery = "SELECT r.RelatedID, i.Item, i.SmImage, i.Keywords FROM " .SB_DB_PREFIX ."_related r, " .SB_DB_PREFIX ."_items i WHERE r.RelatedID = i.ID AND r.ProductID = '" .(int)$prodid ."' AND i.Active='Yes'";
to:
$relquery = "SELECT r.RelatedID, i.Item, i.SmImage, i.Keywords, i.RegPrice, i.SalePrice FROM " .SB_DB_PREFIX ."_related r, " .SB_DB_PREFIX ."_items i WHERE r.RelatedID = i.ID AND r.ProductID = '" .(int)$prodid ."' AND i.Active='Yes'";
-
Add the code:
$rel_chkopts = var_chkopts($rel_id); $rel_pricerange = var_pricerange($rel_chkopts['atts'], $relrow['RegPrice'], $relrow['SalePrice']); if (!empty($rel_pricerange)) $rel_itemlink .= "
" . $rel_pricerange;just under the code:
$rel_itemlink = "$rel_catalog$rel_item";
-
Save and reload the file.
Version 2.8x:
- Change the related query in the product layout files to include additional fields:
- Open the products_detail.php file in the /enc/ folder.
- Change the first part of the $relquery line from:
$relquery = "SELECT " .SB_DB_PREFIX ."_related.RelatedID, " .SB_DB_PREFIX ."_items.Item, " .SB_DB_PREFIX ."_items.SmImage, " .SB_DB_PREFIX ."_items.Keywords FROM " .SB_DB_PREFIX ."_related, " .SB_DB_PREFIX ."_items WHERE ";
to:
$relquery = "SELECT RelatedID, Item, SmImage, Keywords, " .SB_DB_PREFIX ."_items.ID AS RelItemID, RegPrice, SalePrice, OutOfStock, Inventory FROM " .SB_DB_PREFIX ."_related, " .SB_DB_PREFIX ."_items WHERE ";
- Repeat this on the products_single.php and products_multisingle.php files.
- Change the related product file to show prices:
- Open the products_related.php file in the /enc/ folder.
- Add the lines:
$rchkoptsquery = "SELECT Attributes FROM " .SB_DB_PREFIX ."_options WHERE ItemID='" .(int)$relrow[RelItemID] ."' AND Active='Yes' AND OptionNum='1' AND Attributes LIKE '%:%' LIMIT 1"; $rchkoptsresult = mysql_query($rchkoptsquery, $dblink) or die ("Unable to access database."); $rchkoptsnum = mysql_num_rows($rchkoptsresult); $rchkoptsarray = array(); if ($rchkoptsnum == 1) { $rchkoptsrow = mysql_fetch_row($rchkoptsresult); $rchkoptsarray = explode("~", $rchkoptsrow[0]); } $relatedpricerange = var_pricerange($rchkoptsarray, $relrow[RegPrice], $relrow[SalePrice]); $relatedprice = var_showoos($relrow[OutOfStock], $relrow[Inventory], $relatedpricerange);above the line:echo "
"; - Add the lines:
if ($show_prices == "yes") echo "
under the line:
$relatedprice";echo "$relitem";
- Add the lines: