+ Reply to Thread
Results 1 to 2 of 2

Thread: Expand the new Related Items functionality into an Upsell in the Cart feature

  1. #1
    Client
    Join Date
    Sep 2011
    Posts
    4
    Squirrelcart version
    v3.3.5

    Expand the new Related Items functionality into an Upsell in the Cart feature

    In response to http://www.ldev.com/forums/showthrea...oducts-Feature

    It would be great if the related items could optionally be shown in the cart as well, as a way to upsell on an order. I intend on using SC as a checkout not as my store/site, and will be sending a user to the cart each time a product is added.

    So now that we can create relationships between products it would be fantastic if they could be shown in the cart with an Add to Cart option.

  2. #2
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    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";
        }
    }
    ?>

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts