We will most likely be adding code in the future that will allow you to use the related products feature to actually ask the customer if they want to order any of the related products AFTER they add to cart, either on its own page or on the checkout page.
The function we use to display related products is sc_related_products(). Information on how that function works is as follows:
Code:
/*************************************************************************************************************************************
Function: sc_related_products()
Purpose:
Returns products related to $prod_rn, based on the Related Products fieldset on the product record
represented by $prod_rn. Data for this is stored in the REL_Products__Products table.
When $rns_only is NOT set to 1/true, an array is returned containing HTML to display products
When $rns_only is set to 1/true, only the product record numbers are returned
This function closely mirros sc_products in its parameters, and ultimately calls that function for its data.
Parameters:
$prod_rn (mixed) record number of category,
or a full query to grab products
OR an array containing products to show
$tpl (string) template name for template to show a single product
$per_row (integer) number of products per row
$randomize (boolen) Set to 1/true to put products in random order
$max_records (integer) Set to a number equal to the maximum number of records you want returned
$return (mixed) Set to 1 to return an array containing product data. Leave at 0 to return HTML to display all products.
$rns_only (boolean) Set to 1/true to return the product record numbers without additional HTML and other info
History:
File added on 02/23/2011
**************************************************************************************************************************************/
function sc_related_products($prod_rn=false, $tpl=0, $per_row=0, $randomize=0, $max_records=20, $return=0, $rns_only=0){
Add this to your checkout_view.tpl.php template file, and it will show related products for the item just added to the cart:
PHP Code:
<?php
if ($_GET['add_to_cart'] && is_numeric($_GET['prod_rn'])) {
$related_prods = sc_related_products($_GET['prod_rn'],0,3);
if ($related_prods) {
print "Related Products<br/>$related_prods";
}
}
?>