Automatically set cross sell products

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
Post Reply
User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Automatically set cross sell products

Post by mazhar » Tue May 26, 2009 8:46 am

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"]]

Post Reply