In Your Static block suppose this is the product add to cart link:

<a href="javascript::void();" onclick="addtocartfeatureProduct(34)">
<strong>Buy ></strong>
</a>

you need to call a function with parameter of product id,

in your header write a script with the following code:

<script type="text/javascript">
		 function addtocartfeatureProduct (id){
			//alert(pid);
			var url = '<?php echo $this->getBaseUrl() ?>products/index/featureproductadd';
			var senddata = {'pid':id};
			jQuery.ajax({
			   url: url,
			   type: "POST",
			   data: senddata,
			   success: function(data) {
			      setLocation(data);
			   },
			});
		 }
	  </script>

and inside the controller add the function:

public function featureproductaddAction() {
		
		$product_id = $this->getRequest()->getPost('pid');
		$product = Mage::getModel('catalog/product')->load($product_id);
		$url = Mage::helper('checkout/cart')->getAddUrl($product);
		echo $url;
    }

working-on-a-computer-smiley-emoticon

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

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