I'm new to Magento. I want to add the buy now button along with the Add to cart button on the product page. I have searched for that, I found this solution :
<button type="button" title="<?php echo $this->__('Check out') ?>" class="button btn-cart" onclick="setcheckoutLocation('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo Mage::getUrl('checkout/onepage') ?>')"><span><span><?php echo $this->__('Buy Now') ?></span></span></button>
<script>
function setcheckoutLocation(location,chkout)
{
jQuery.ajax({
type:"GET",
url:location,
success:function(data){
window.location.href = chkout;
}
});
}
</script>
But it add the product to cart and then redirects to onepage and in the checkout process, all the products that are in the cart are added.
Is There any way that the product which we have selected for buy now will only be added to the checkout process regardless of products in the cart. Thanks in advance.
Best Answer
Hello @Srikant you have to create a form on the product page and the action should be checkout link :
In url $product is product object
Now clicking on the buy now you will be redirected to the checkout page directly. The form should be individual for each product.