Page 1 of 1

Automatically set cross sell products

Posted: Tue May 26, 2009 8:46 am
by mazhar
This small mod attempts to automate the product cross sell(similar products) maintenance.
Every time a customer places an order, all products that are in the shopping cart are linked as cross sell(similar products) products.

In order to install the mod, download and extract CrossSellHelper.zip file and then follow following instructions.

1:- Place CrossSellHelper.cs file into your websites App_Code folder.
2:- Now edit you ConLib/OnePageCheckout.ascx.cs file and locate following code block

Code: Select all

 private bool _AllowAnonymousCheckout = false;
    public bool AllowAnonymousCheckout
    {
        get { return _AllowAnonymousCheckout; }
        set { _AllowAnonymousCheckout = value; }
    }
and make it look like

Code: Select all

private bool _AllowAnonymousCheckout = false;
    public bool AllowAnonymousCheckout
    {
        get { return _AllowAnonymousCheckout; }
        set { _AllowAnonymousCheckout = value; }
    }

    private bool _EnableAutoCrossSell = false;
    public bool EnableAutoCrossSell
    {
        get { return _EnableAutoCrossSell; }
        set { _EnableAutoCrossSell = value; }
    }
3:- Now locate following code in CheckedOut method

Code: Select all

else
        {
            CheckoutMessagePanel.Visible = true;
            CheckoutMessage.Text = string.Join("<br /><br />", response.WarningMessages.ToArray());
        }
and change it as below

Code: Select all

else
        {
            CheckoutMessagePanel.Visible = true;
            CheckoutMessage.Text = string.Join("<br /><br />", response.WarningMessages.ToArray());
        }
        if (EnableAutoCrossSell)
        {
            Order order = OrderDataSource.Load(e.OrderId, false);
            if (order != null)
                CrossSellHelper.MarkCrossSells(order.Items);
        }
4:- Finally in order to enable auto cross sell, edit your checkout scriptlet and then set EnableAutoCrossSell to true as below

Code: Select all

[[ConLib:OnePageCheckout EnableAutoCrossSell="true"]]