Affiliate Add to Cart?
Affiliate Add to Cart?
Is there a way for an affiliate or an external entity to allow customers to add products to the cart from their website? For instance, a customer wants to buy a product that I carry but they are on an affiliate's website. When they click add to cart, it takes them to my shopping cart.
Thanks in advance!
Thanks in advance!
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Affiliate Add to Cart?
I don't think so that currently any page is providing this facility. But this can be incorporated into ac7 very easily with some small changes. You can create some user control which can handle this type of functionality when placed over some page.

Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Affiliate Add to Cart?
Create a new file ConLib/AddToCartEx.ascx and put the following code in it.
Now place this control on some page like any normal ConLib control. And place the URL of this page on the site from where you want to send the product to cart. The URL must be contain the Product Id of the desired product. For example
I hope so this sample will help you.
Code: Select all
<%@ Control Language="C#" ClassName="AddToCartEx" %>
<script runat="server">
private int _ProductId;
protected void Page_Load(object sender, EventArgs e)
{
_ProductId = PageHelper.GetProductId();
if (_ProductId > 0)
AddToCart();
}
protected void AddToCart()
{
//GET THE PRODUCT ID FROM THE URL
Product product = ProductDataSource.Load(_ProductId);
if (product != null)
{
string lastShoppingUrl = NavigationHelper.GetLastShoppingUrl();
if (product.HasChoices || product.UseVariablePrice)
{
//CANT ADD DIRECTLY TO BASKET, SEND TO MORE INFO
Response.Redirect(product.NavigateUrl);
}
BasketItem basketItem = BasketItemDataSource.CreateForProduct(_ProductId, 1);
if (basketItem != null)
{
// DETERMINE IF THE LICENSE AGREEMENT MUST BE REQUESTED
BasketItemLicenseAgreementCollection basketItemLicenseAgreements = new BasketItemLicenseAgreementCollection(basketItem, LicenseAgreementMode.OnAddToBasket);
if ((basketItemLicenseAgreements.Count > 0))
{
// THESE AGREEMENTS MUST BE ACCEPTED TO ADD TO BASKET
List<BasketItem> basketItems = new List<BasketItem>();
basketItems.Add(basketItem);
string guidKey = Guid.NewGuid().ToString("N");
Cache.Add(guidKey, basketItems, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), System.Web.Caching.CacheItemPriority.NotRemovable, null);
string acceptUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("~/Basket.aspx"));
string declineUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Page.ResolveClientUrl(product.NavigateUrl)));
Response.Redirect("~/BuyWithAgreement.aspx?Items=" + guidKey + "&AcceptUrl=" + acceptUrl + "&DeclineUrl=" + declineUrl);
}
//ADD ITEM TO BASKET
Basket basket = Token.Instance.User.Basket;
basket.Items.Add(basketItem);
basket.Save();
//Determine if there are associated Upsell products
if (basketItem.Product.GetUpsellProducts(basket).Count > 0)
{
//redirect to upsell page
string returnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Request.Url.ToString()));
Response.Redirect("~/ProductAccessories.aspx?ProductId=" + basketItem.ProductId + "&ReturnUrl=" + returnUrl);
}
// IF BASKET HAVE SOME VALIDATION PROBLEMS MOVE TO BASKET PAGE
List<string> basketMessages;
if (!basket.Validate(out basketMessages))
{
Session.Add("BasketMessage", basketMessages);
Response.Redirect(NavigationHelper.GetBasketUrl());
}
//IF THERE IS NO REGISTERED BASKET CONTROL, WE MUST GO TO BASKET PAGE
if (!PageHelper.HasBasketControl(this.Page)) Response.Redirect(NavigationHelper.GetBasketUrl());
}
}
}
</script>
<asp:Label ID="Label1" runat="server" Text="Add products to cart from affliates site." Font-Bold="true"></asp:Label>
Code: Select all
http://www.somesite.com/mypage.aspx?ProductId

Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com
Re: Affiliate Add to Cart?
Hi,
I'm new to AbleCommerce and am trying to make use of the external add to cart functionality.
I've added the user control and added the conlib referenc on a page but when i visit the page it redirects me to the product page and doesn't add anything to the basket.
I'm not quite sure what additional information I should provide in this case.
If anybody has gotten this to work or can help out let me know what other information I can provide to troubleshoot this.
Thanks,
Chad
I'm new to AbleCommerce and am trying to make use of the external add to cart functionality.
I've added the user control and added the conlib referenc on a page but when i visit the page it redirects me to the product page and doesn't add anything to the basket.
I'm not quite sure what additional information I should provide in this case.
If anybody has gotten this to work or can help out let me know what other information I can provide to troubleshoot this.
Thanks,
Chad
Chad Peppers
http://www.jewellgroup.com/
http://www.jewellgroup.com/
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Affiliate Add to Cart?
Do your products have options? It won't work in that case.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Affiliate Add to Cart?
Thanks for pointing me in the right direction Judy.
I was originally testing this with a kit product.
Is there any way paramaters could be constructed for kit/option items?
I was originally testing this with a kit product.
Is there any way paramaters could be constructed for kit/option items?
Chad Peppers
http://www.jewellgroup.com/
http://www.jewellgroup.com/
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Affiliate Add to Cart?
There probably are, since it could be done in Able 5. I just haven't experimented, but you could try adding a kit to the basket from the normal product page and putting code on the basket page to display the parameters it is using.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx