Skip to content

Instantly share code, notes, and snippets.

@seedprod
Created October 8, 2019 13:35
Show Gist options
  • Save seedprod/fbaeaa2d3b5728f9871f57863b108a77 to your computer and use it in GitHub Desktop.
Save seedprod/fbaeaa2d3b5728f9871f57863b108a77 to your computer and use it in GitHub Desktop.
document.addEventListener('om.Campaign.afterShow', function(event) {
// exit offer
if(event.detail.Campaign.numericId == '212237'){
var offer_ajax_url = '/checkout/exit_offer';
console.log( _self.$data);
axios
.post(offer_ajax_url,
_self.$data
).then(function (response) {
if(response.data){
window.scrollTo(0,0);
_self.msg = 'Complete your checkout now and get 30% off!';
_self.coupon_code = 'COMPLETE30E';
_self.$refs.hcoupon.value = 'COMPLETE30E';
_self.discount = '-$' + (parseFloat(response.data.discounts[0].amount / 100).toFixed(2));
_self.discount_applied = 1;
_self.total = '$' + (parseFloat(response.data.total / 100).toFixed(2));
}
}).catch(function(error) {
console.log(error);
});
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment