Currently the Also Bought control lists the other items sold on product details page. If you want to put the control over basket page to list other sold items then you need to made some modifications in the control code.

First download the Also Bought control from here
Also Bought Control

Extract the attachment and edit the AlsoBought.ascx.cs file and replace the Page_Load and GetOtherBoughtProducts methods with following updated versions.

1
2
3
4
5
6
7
8
9
10
11
12
13
protected void Page_Load(object sender, EventArgs e)
{
phCaption.Text = this.Caption;
int userId = Token.Instance.UserId;
int productId = PageHelper.GetProductId();
ProductCollection products = GetOtherBoughtProducts();
if (products !=null && products.Count > 0)
{
ProductList.DataSource = products;
ProductList.DataBind();
}
else phContent.Visible = false;
}

and

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
private ProductCollection GetOtherBoughtProducts()
{
ProductCollection products = new ProductCollection();
string basketItemIds = string.Empty;
foreach (BasketItem basketItem in Token.Instance.User.Basket.Items)
{
if (basketItem.OrderItemType == OrderItemType.Product)
basketItemIds = basketItem.ProductId.ToString() ",";
}
if (!String.IsNullOrEmpty(basketItemIds))
basketItemIds = basketItemIds.Remove(basketItemIds.Length - 1, 1);
else
return products;
Database database = Token.Instance.Database;
DbCommand selectCommand = database.GetSqlStringCommand("SELECT DISTINCT TOP " MaxItems.ToString() " OI.ProductId FROM ac_OrderItems AS <a href="http://www.nbso.ca/">nbso</a>  OI WHERE OI.OrderId IN ( SELECT OrderId FROM ac_OrderItems WHERE ProductId IN ( " basketItemIds " ) ) AND OI.ProductId NOT IN ( " basketItemIds " ) ");
ArrayList recentOrderIds = new ArrayList();
using (IDataReader reader = database.ExecuteReader(selectCommand))
{
while(reader.Read())
{
int aProductId = AlwaysConvert.ToInt(reader[0]);
if (aProductId &gt; 0)
{
Product aProduct = ProductDataSource.Load(aProductId);
products.Add(aProduct);
}
}
}
return products;
}

Save the file and use the control on Basket page.

1
[[ConLib:AlsoBought Orientation="HORIZONTAL" Columns="4" MaxItems="16"]]

NOTE You may need to change the MaxItems value from default 4 to some large number like 10 because if there are more items in basket then possibly there could be a large number of other sold items related to them.

Screen Shot
alsobought-basket

Also Bought Control for Basket Page
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *