简体   繁体   中英

Magento – Coupon Code Submit Button Not Working

I have a fetch to which a strange magento situation. The template or extensions they installed seamed to have broken the coupon code submit button on their cart page. People could not submit a coupon code by clicking the “Apply Coupon” button. They had to hit enter. i have could not find the javascript that was producing the error.

Any solutions for this.

I was found to the solution is quite simple.

Find the pesky code:

<button type="button" title="Apply Coupon" onclick="discountForm.submit(false)" value="Apply Coupon"><span><span>Apply Coupon</span></span></button>

and change it to:

<button title="Apply Coupon" onclick="discountForm.submit(false)" value="Apply Coupon"><span><span>Apply Coupon</span></span></button>

By removing type=”button” the error seems to correct itself. After removing the type, the button magically started working again! I know this treating the symptom not the problem, but hey it works.

** 100% working this solution ** Find this code (Line 39 in notepad++) in your coupon.phtml file.

<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Apply Coupon')) ?>" class="button" onclick="discountForm.submit(false)" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Apply Coupon')) ?>"><span><span><?php echo $this->__('Apply Coupon') ?></span></span></button>

*replace with is code *

<button type="Apply Coupon" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Apply Coupon')) ?>" class="button" onclick="discountForm.submit(false)" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Apply Coupon')) ?>"><span><span><?php echo $this->__('Apply Coupon') ?></span></span></button>

clear your cache and check once again it's should be works

The solution that Bhavesh has posted here seems to be a quick around, but cant work always.

Most Magento themes uses "prototype.js" as the javascript framework to handled the client interactions. Sometimes we misunderstand the variable "$" used here with the jquery variable and we may end up using jquery as well in the pages to customize the page.

in such a case we end up using 2 javascript frameworks "prototype.js" and "jQuery" in the same website which will result in conflict. It is this conflict that makes the coupon button not to work.

In order to resolve this you shall do the following:

  1. Use the jQuery conflict resolve option and assign any other variable other than "$" for calling jquery. eg: $(".flowplayer .info").hover should be changed to jQuery(".flowplayer .info").hover
  2. The second this that you could do is to call the prototype script after calling the jquery script.

eg

<script type="text/javascript" src="http://mywebsite/js/jquery.tools.min.js">

<script type="text/javascript">jQuery.noConflict();</script>

<script type="text/javascript" src="http://mywebsite/js/prototype/prototype.js"></script>

The solution that @Bhavesh has posted here seems to be a quick around, but cant work always.

Most Magento themes uses prototype.js as the javascript framework to handle the client interactions. Sometimes we misunderstand the variable $ used here with the jquery variable and we may end up using jquery as well in the pages to customize the page.

in such a case we end up using 2 javascript frameworks prototype.js and jQuery in the same website which will result in conflict. It is this conflict that makes the coupon button not to work.

In order to resolve this you shall do the following:

Use the jQuery conflict resolve option and assign any other variable other than $ for calling jquery. eg: $(".flowplayer .info").hover should be changed to jQuery(".flowplayer .info").hover The second this that you could do is to call the prototype script after calling the jquery script. eg

<script type="text/javascript" src="http://mywebsite/js/jquery.tools.min.js">
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript" src="http://mywebsite/js/prototype/prototype.js"></script>

I fixed it by changing the type to submit. Fixed both the apply and cancel buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM