When I apply a coupon code on cart page and then submit it automatically, the customer is redirected to home page and show success message in home page only.
How to avoid the redirect, stay on the same page and show the success message on the cart page?
<form id="discount-coupon-form" action="<?php echo $this->getUrl('checkout/cart/couponPost') ?>" method="post">
<div class="discount">
<div class="discount-form">
<input type="hidden" name="remove" id="remove-coupone" value="0" />
<div class="input-box">
<input class="input-text" id="coupon_code" name="coupon_code" value="<?php echo $this->escapeHtml($this->getCouponCode()) ?>" placeholder="Enter Your Coupen code if you have...." />
</div>
<div class="buttons-set">
<button type="button" title="<?php echo $this->__('Apply Coupon') ?>" class="button" onclick="discountForm.submit(false)" value="<?php echo $this->__('Apply Coupon') ?>"><span><span><?php echo $this->__('Apply Coupon') ?></span></span></button>
<?php if(strlen($this->getCouponCode())): ?>
<button type="button" title="<?php echo $this->__('Cancel Coupon') ?>" class="button" onclick="discountForm.submit(true)" value="<?php echo $this->__('Cancel Coupon') ?>"><span><span><?php echo $this->__('Cancel Coupon') ?></span></span></button>
<?php endif;?>
</div>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var discountForm = new VarienForm('discount-coupon-form');
discountForm.submit = function (isRemove) {
if (isRemove) {
$('coupon_code').removeClassName('required-entry');
$('remove-coupone').value = "1";
} else {
$('coupon_code').addClassName('required-entry');
$('remove-coupone').value = "0";
}
return VarienForm.prototype.submit.bind(discountForm)();
}
//]]>
</script>
$this->getChildHtml('global_messages')
. But even if there is none, your redirect to the homepage is not normal. Can you give more info please. Are you using a commercial template? Please post the complete HTML form-node of the coupon input field.