IF we click on "Buy now " button in view page
its redirecting to cart page. we are using following code :
<button class="button buy-now" onclick=”location.href =’{{config path=”web/unsecure/base_url”}}/checkout/cart/add?product=1&qty=1′”>
<span><span><i class="fa fa-shopping-cart"></i>Buy Now</span></span></button>
we are using following code for "Add to cart" button, what we need is if we click on "add to cart" button,
than it should redirect to cart page.
<button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart"
onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
edit
JS code :
productAddToCartForm.submit = function(button, url) {
if (('undefined' != typeof productAddToCartFormOld) && productAddToCartFormOld) {
if (Catalog.Map.active) {
Catalog.Map.hideHelp();
}
if (productAddToCartForm.qty && $('qty')) {
$('qty').value = productAddToCartForm.qty;
}
parentResult = productAddToCartFormOld.submit();
return false;
}
if(window.opener) {
var parentButton = button;
new Ajax.Request(this.form.action, {
parameters: {isAjax: 1, method: 'GET'},
onSuccess: function(transport) {
window.opener.focus();
if (parentButton && parentButton.href) {
setPLocation(parentButton.href, true);
Catalog.Map.hideHelp();
}
}
});
return;
}
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
if (!form.getAttribute('action')) {
form.action = productAddToCartForm.action;
}
try {
this.form.submit();
} catch (e) {
this.form.action = oldUrl;
throw e;
}
this.form.action = oldUrl;
if (button && button != 'undefined') {
button.disabled = true;
}
}
};