Skip to content

Instantly share code, notes, and snippets.

@ceckoslab
Created January 10, 2013 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ceckoslab/4503260 to your computer and use it in GitHub Desktop.
Save ceckoslab/4503260 to your computer and use it in GitHub Desktop.
Workaround to unbind the event listeners for the agreement checkboxes
<script type="text/javascript">
//<![CDATA[
// submit buttons are not needed when submitting with ajax
$('review_submit').hide();
if ($('update_shipping_method_submit')) {
$('update_shipping_method_submit').hide();
}
<?php if ($this->getUseAjax()):?>
OrderReviewController.prototype._submitOrder = function() {
if (this._canSubmitOrder) {
if (this._pleaseWait) {
this._pleaseWait.show();
}
new Ajax.Request(this.form.action, {
parameters: {isAjax: 1, method: 'POST'},
onSuccess: function(transport) {
try{
response = eval('(' + transport.responseText + ')');
} catch (e) {
response = {};
}
if (response.redirect) {
setLocation(response.redirect);
return;
}
if (response.success) {
setLocation('<?php echo $this->getSuccessUrl()?>');
return;
} else {
var msg = response.error_messages;
if (typeof(msg)=='object') {
msg = msg.join("\n");
}
if (msg) {
$('review-please-wait').hide();
alert(msg);
return;
}
}
$('review-please-wait').hide();
alert('<?php echo $this->jsQuoteEscape($this->__('Unknown Error. Please try again later.')); ?>');
return;
},
onFailure: function(){
alert('<?php echo $this->jsQuoteEscape($this->__('Server Error. Please try again.')) ?>');
$('review-please-wait').hide();
}
});
}
}
<?php endif ?>
PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'),
'shipping_method', null, 'details-reload'
);
PayPalExpressAjax.addPleaseWait($('review-please-wait'));
PayPalExpressAjax.setShippingAddressContainer($('shipping-address'));
PayPalExpressAjax.setShippingMethodContainer('shipping-method-container');
PayPalExpressAjax.shippingMethodsUpdateUrl = '<?php echo $this->escapeHtml($this->getUpdateShippingMethodsUrl()) ?>';
PayPalExpressAjax.setUpdateButton($('update_order'),'<?php echo $this->escapeHtml($this->getUpdateOrderSubmitUrl()) ?>','details-reload');
if ($('billing:as_shipping')) {
PayPalExpressAjax.setCopyElement($('billing:as_shipping'));
}
//Workaround to unbind the event listeners for the agreement checkboxes
var agreementsBlock = $$('.checkout-agreements p.agree')[0];
if(agreementsBlock != undefined) {
agreementsBlock.replace('<p class="agree">' + agreementsBlock.innerHTML + '</p>');
}
//]]>
</script>
@thorstenfriesen
Copy link

Thanks!! But if you have more than one checkboxes you can use:
https://gist.github.com/thorstenfriesen/5574702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment