jQuery(document).ready(function(){jQuery(document.body).on("updated_checkout",async function(){console.clear();await getMypostRatesRequestLogs();});jQuery(document.body).on("updated_cart_totals",async function(){console.clear();await getMypostRatesRequestLogs();});});async function getMypostRatesRequestLogs(){const response=await jQuery.ajax({type:"get",url:mypost_cart_checkout.ajax_url,data:{action:"easypost_get_rates_request_logs",_ajax_nonce:mypost_cart_checkout.nonce,},dataType:"json",});if(response?.success&&response?.data){const responseData=response?.data;if(responseData?.mypost_rates_logs){console.log(responseData?.mypost_rates_logs?.replaceAll("%colored_text_start%","%c")?.replaceAll("%colored_text_end%","%c"),responseData?.mypost_rates_logs?.includes("%colored_text_start%")?"color: red":"",responseData?.mypost_rates_logs?.includes("%colored_text_end%")?"color: initial":"");}}}
jQuery(document).ready(function(){const originalFetch=window.fetch;window.fetch=new Proxy(originalFetch,{apply:async function(target,thisArg,argumentsList){const url=argumentsList[0];const options=argumentsList[1];if(url.includes("/wp-json/wc/store/")&&options&&options.method==="POST"){const response=await target.apply(thisArg,argumentsList);if(window?.wp?.data?.select("wc/store/cart")?.getCartData()){getMypostRatesRequestLogs();}return response;}else{return target.apply(thisArg,argumentsList);}},});});