Skip to content '; function getCoupon(){ var d = new Date(); var dateTime = d.toISOString(); if(api_points_parse.creditsToCurrencyRatio = 1){ // alert('1'); var annexredeem = parseInt(document.getElementById("annex_redeem").value); if( annexredeem == 10){ var points = 200; } if(annexredeem == 20){ var points = 300; } if(annexredeem == 30){ var points = 400; } if(annexredeem == 50){ var points = 500; } // alert(annexredeem+","+points); } else{ var points = parseInt(document.getElementById("annex_redeem").value) * api_points_parse.creditsToCurrencyRatio; } var shop_p_domain = 'tradehomeshoes-dev.myshopify.com'; var data = {'store_id':shop_p_domain, 'payload': parseInt(document.getElementById("annex_redeem").value), 'points': points, 'user_id':email,'customer_id':customer_id, 'date':dateTime, 'action':'create_rule'}; $.ajax({ type: 'POST', url: shop_url+'/apps/loyalty/jwt_generator.php', data: JSON.stringify(data), dataType: "json", success: function(res) { if(res.errorcode == 0){ //document.getElementById("checkout_reduction_code").value = res.data[0].discount_code; $("input[name='checkout[reduction_code]']").val(res.data[0].discount_code); discount_id = res.data[0].discount_id; window.localStorage.setItem('stored_discount_id', discount_id); rule_id = res.data[0].rule_id; window.localStorage.setItem('stored_rule_id', rule_id); var apply_copon_btn = document.getElementsByClassName("field__input-btn btn btn--disabled"); apply_copon_btn[0].removeAttribute("disabled"); apply_copon_btn[0].className = "field__input-btn btn"; $(".field__input-btn").trigger("click"); var stored_currency_bal = api_points_parse.creditsToCurrencyValue - annex_redeem; var stored_points_bal = api_points_parse.availablePoints - points; //window.localStorage.setItem('stored_currency_bal', stored_currency_bal); window.localStorage.setItem('stored_points_bal', stored_points_bal); /*change the value of currence and points elements START*/ //document.getElementsByClassName("currency_bal")[0].innerHTML = "Your currency balance:
"+stored_currency_bal+" "; document.getElementsByClassName("points_bal")[0].innerHTML = "Your available points:
"+stored_points_bal+" "; /*change the value of currence and points elements END*/ /*replace annex textbox and apply button with cancel button START*/ removePointsBox(); setInterval(function(){ initClose(); }, 2000); /*replace annex textbox and apply button with cancel button END*/ } else if(res.errorcode == 0){ document.getElementById("annex_redeem").style.borderColor = "red"; return false; } } }); } getCoupon(); } } else{ document.getElementById("annex_redeem").style.borderColor = "red"; return false; } } else{ document.getElementById("annex_redeem").style.borderColor = "red"; return false; } } /*remove discount START*/ function removeDiscount(){ function removeCoupon(){ if(discount_id == ""){ discount_id = window.localStorage.getItem('stored_discount_id'); } if(rule_id == ""){ rule_id = window.localStorage.getItem('stored_rule_id'); } var shop_p_domain = 'tradehomeshoes-dev.myshopify.com'; var data = {'store_id':shop_p_domain, 'discount_id': discount_id, 'rule_id': rule_id, 'user_id':email,'customer_id':customer_id, 'action':'delete_discount'}; $.ajax({ type: 'POST', url: shop_url+'/apps/loyalty/jwt_generator.php', data: JSON.stringify(data), dataType: "json", success: function(res) { if(res.errorcode == 0){ /*remove applied coupon START*/ if(document.getElementsByClassName("tag__button")){ var remove_btn = document.getElementsByClassName("tag__button");$("#cancel_dollar_button").trigger("click"); /*remove applied coupon END*/ } window.localStorage.removeItem('stored_discount_id'); window.localStorage.removeItem('stored_rule_id'); // window.localStorage.removeItem('stored_currency_bal'); window.localStorage.removeItem('stored_points_bal'); setTimeout(function(){ updateLoyaltyTotals(); }, 2000); } } }); } removeCoupon(); } /*remove discount END*/ function updateLoyaltyTotals(){ getPoints(); } function updateLoyaltyTotalsFix(){ //document.getElementsByClassName("currency_bal")[0].innerHTML = "Your currency balance:
"+window.localStorage.getItem('stored_currency_bal')+" "; document.getElementsByClassName("points_bal")[0].innerHTML = "Your available points:
"+window.localStorage.getItem('stored_points_bal')+" "; } function addPointsBox(){ var list = document.getElementById("apply_dollar_button_wrapper"); list.classList.remove("hidden"); list.innerHTML = '
Pay with Annex Cloud Balance
'+ ''; updateLoyaltyTotalsFix(); } function removePointsBox(){ document.getElementById("apply_dollar_button_wrapper").innerHTML = ""; document.getElementById("apply_dollar_button_wrapper").classList.add("hidden"); } function initClose(){ $('.sidebar__content .tag__button').first().attr('id','cancel_dollar_button'); $('.sidebar__content .tag__button').first().attr('onclick','removeDiscount()'); } /* checking of existing discount BEGIN */ $(document).on('page:load', function () { $(window).on('load', function() { setTimeout(function(){ var checkDiscountCode = $('span.reduction-code__text'); if(checkDiscountCode.is(':contains("ANNEX")')) { removePointsBox(); updateLoyaltyTotalsFix(); initClose(); } else{$('div#apply_dollar_button_wrapper').removeClass('hidden'); } }, 3000); }); }); /* checking of existing discount END*/
Free Shipping on orders $50+
Rewards Stores Cart 0 Sign In Shop the latest styles in boy's shoes ranging from infant to grade school. Styles include sandals, boots, sneakers and more for any occasion.
1 point for every $1 spent
Free shipping over $50
Free returns and exchanges in store
Be the first to know about exclusive offers Company About Careers Sustainability Store Locator Gift Cards Account Sign In Register Rewards Military Discount Dashboard Track Orders Help FAQs Contact Shipping Sitemap
Copyright © 2024 by Tradehome Shoes. All Rights Reserved. Privacy policy