cancel
Showing results for 
Search instead for 
Did you mean: 

Adding product to cart via an external link

Adding product to cart via an external link

Hi,

Could you please help me adding product to cart via an external link. i wan to add a product link on ad-words website so customer can click on the link and directly go to magento basket page.

 

Thanks

Mazhar

3 REPLIES 3

Re: Adding product to cart via an external link

Hi @Bestsleepever!

 

What version of Magento are you on?

 

Since Magento 1.8, it's no longer possible to add a product to the cart via an external link.

 

It may be possible to achieve this with some custom development, please see this answer on the Magento Stack Exchange: 

https://magento.stackexchange.com/questions/37779/i-want-to-use-add-to-cart-via-url-in-magento-1-8-b...

 

Any further questions, let me know Smiley Happy 

Problem solved? Click Accept as Solution!
Follow me on twitter:@RebeccaBrocton | wearejh.com

Re: Adding product to cart via an external link

Hi @Bestsleepever!

 

I think you can do via core php using iframe.

it is just an idea.

create a module and pass the $product object in the phtml file. after that create only "add to cart" like:

$product=Mage::getModel('catalog/product')->load($productId);//load the product by product id
$product=Mage::getModel('catalog/product')->loadByAttribute('sku',$skuNum);//or load the product by sku number
$product=Mage::getModel('catalog/product')->setStoreId($storeId)->loadByAttribute('sku',$skuNum);//or load the product from a given store id
 
$url = Mage::helper('checkout/cart')->getAddUrl($product);
 
<form action = "<?php echo $url;?> ">
<input type='hidden' name="product_id" value="$productId" />
<button type="submit" value="Add to cart" />
</form>
 
You can try with it.

Thanks
Vishal S

Re: Adding product to cart via an external link

@vishalsanwar86  How can i add add-to-cart button on below code

 

<div class="thumb col-md-2 col-xs-6" data-target="#carousel" data-slide-to="15">
<a itemprop="name" href="https://abc.com/apple">
<img class="img-responsive" alt="apple" src="https://abc.com/media/catalog/product/cache/1/image/700x700//9/1/111111111111001441-1.jpg" /></a><br />
<p>Apple</p>
</div>

I am using above code in my blog post, here how can i add addtocart button