View Single Post
  #1  
Old 05-14-2019, 04:59 PM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,964
 

Default 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
__________________
X-Cart GoldPlus v4.7.12 | reBOOT (reDUX) Template v4.7.12.9 | Always The Best
Reply With Quote