X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   Altered Carts - Cash Rewards changes for jQuery 3.4.0 (https://forum.x-cart.com/showthread.php?t=76960)

elmirage001 05-14-2019 04:59 PM

Altered Carts - Cash Rewards changes for jQuery 3.4.0
 
I'm still using Altered Carts Cash Rewards and I had to make a few changes for it to work with jQuery 3.4.0 on 4.7.11.

In skin/common_files/modules/One_Page_Checkout/ajax.checkout.js the new 3 blocks of code are.


Code:

// Cash Rewards :: www.alteredcart.com //
s._applyRewards = function(e) {
return !s.applyRewards(this, e);
};
s._unsetRewards = function(e) {
return !s.unsetRewards(this, e);
};
// Cash Rewards :: www.alteredcart.com //


Code:

// Cash Rewards :: www.alteredcart.com //
ajax.widgets.checkout.obj.prototype.applyRewards = function(elm){
if (!this.isReady() || !this.checkElement()) {
return false;
}
var container = $('#applyCashRewardsContainer');
var form = $('#applyCashRewardsContainer form');
var s = this;

this.totals.block();

return ajax.query.add({
type: 'GET',
url: 'cart.php?action=apply_rewards',
data: {rewards_amount:$('#available_rewards_text_field').val()},
success: function(a, b, c, d) {
for (var i = 0; i < c.messages.length; i++) {
if (c.messages[i].name == 'opcUpdateCall' && c.messages[i].params.action) {
$('#applyCashRewardsContainer')[0].innerHTML = c.messages[i].params.display;
break;
}
}

s._updateTotals();
},
error: function(a, b, c, d) {
return s.callback(false, a, b, c, d);
}
}
) !== false;
};
ajax.widgets.checkout.obj.prototype.unsetRewards = function(elm) {
if (!this.isReady() || !this.checkElement()) {
return false;
}
var container = $('#applyCashRewardsContainer');
var form = $('#applyCashRewardsContainer form');
var s = this;

this.totals.block();

return ajax.query.add({
type: 'GET',
url: 'cart.php?action=unset_rewards',
data: {},
success: function(a, b, c, d) {
s._updateTotals();
},
error: function(a, b, c, d) {
return s.callback(false, a, b, c, d);
}
}
) !== false;
};
// Cash Rewards :: www.alteredcart.com //


Code:

// Cash Rewards :: www.alteredcart.com //
  $(document).on('click','.unsetCashRewards',this._unsetRewards);
  $(document).on('click','.applyRewardButton',this._applyRewards);
// Cash Rewards :: www.alteredcart.com //


The only changes in the first 2 blocks were adding a ; after the last }

The 3rd block used .live with is deprecated ( http://api.jquery.com/live/ ) and I had to change to .on with it's formatting change. It's working for me on my dev 4.7.11 site but use at your own risk as this is way above my pay scale :-)

Paul


All times are GMT -8. The time now is 07:13 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.