JezK
Edit File: frontend.min.js
(m=>{function e(){let a=cartflows.default_page_builder;m('a[href*="wcf-up-offer-yes"]').each(function(e){var t=m(this);0===e?"bricks-builder"===a?t.attr("class","wcf-upsell-offer"):t.attr("id","wcf-upsell-offer"):"bricks-builder"===a?t.attr("class","wcf-upsell-offer-"+e):t.attr("id","wcf-upsell-offer-"+e)}),m('a[href*="wcf-down-offer-yes"]').each(function(e){var t=m(this);0===e?"bricks-builder"===a?t.attr("class","wcf-downsell-offer"):t.attr("id","wcf-downsell-offer"):"bricks-builder"===a?t.attr("class","wcf-downsell-offer"):t.attr("id","wcf-downsell-offer-"+e)}),m(document).on("click",'a[href*="wcf-up-offer"], a[href*="wcf-down-offer"]',function(n){if(n.preventDefault(),!0===cartflows.is_pb_preview)n.stopPropagation();else{var n=m(this),_=n.attr("href"),c=cartflows_offer.step_id,i=cartflows_offer.product_id,s=cartflows_offer.order_id,f=cartflows_offer.order_key,d=cartflows.current_flow;let e="yes",a="upsell",r=0,o=0;if(-1!==_.indexOf("wcf-up-offer")&&(a="upsell",e=-1!==_.indexOf("wcf-up-offer-yes")?"yes":"no"),-1!==_.indexOf("wcf-down-offer")&&(a="downsell",e=-1!==_.indexOf("wcf-down-offer-yes")?"yes":"no"),"yes"===e){_=m(".wcf-offer-product-variation");if(0<_.length){var _=_.find(".variations_form"),l=_.find("input.variation_id");if(r=parseInt(l.val()),0<m(".var_not_selected").length||""===r||0===r)return _.find(".variations select").each(function(){0===m(this).val().length&&m(this).addClass("var_not_selected")}),m([document.documentElement,document.body]).animate({scrollTop:_.find(".variations select").offset().top-100},1e3),!1}}if(!!n.attr("disabled"))return!1;if(n.attr("disabled",!0),"yes"!==cartflows_offer.skip_offer||"yes"!==e){m("body").trigger("wcf-show-loader",e),action="yes"===e?"wcf_"+a+"_accepted":"wcf_"+a+"_rejected";var p,w,l=m(".wcf-offer-product-quantity");0<l.length&&(_=l.find('input[name="quantity"]'),0<(n=parseInt(_.val())))&&(o=n);let t={action:"",offer_action:e,offer_type:a,step_id:c,product_id:i,variation_id:r,input_qty:o,order_id:s,order_key:f,flow_id:d,stripe_sca_payment:!1,stripe_intent_id:"",_nonce:""};return"yes"===e?"stripe"===cartflows_offer.payment_method?(t.action="wcf_stripe_sca_check",t._nonce=cartflows_offer.wcf_stripe_sca_check_nonce,m.ajax({url:cartflows.ajax_url,data:t,dataType:"json",type:"POST",success(e){e.hasOwnProperty("intent_secret")?Stripe(e.stripe_pk).handleCardPayment(e.intent_secret).then(function(e){if(e.error)throw e.error;"requires_capture"!==e.paymentIntent.status&&"succeeded"!==e.paymentIntent.status||(t.action=action,t.stripe_sca_payment=!0,t.stripe_intent_id=e.paymentIntent.id,u(t))}).catch(function(){window.location.reload()}):(t.action=action,u(t))}})):"mollie_wc_gateway_creditcard"===cartflows_offer.payment_method||"mollie_wc_gateway_ideal"===cartflows_offer.payment_method?(p=t,"mollie_wc_gateway_creditcard"===(l=cartflows_offer.payment_method)&&(p.action="wcf_mollie_creditcard_process",p._nonce=cartflows_offer.wcf_mollie_creditcard_process_nonce),"mollie_wc_gateway_ideal"===l&&(p.action="wcf_mollie_ideal_process",p._nonce=cartflows_offer.wcf_mollie_ideal_process_nonce),m.ajax({url:cartflows.ajax_url,data:p,dataType:"json",type:"POST",success(e){"success"===e.result?window.location.href=e.redirect:(p.action=action,u(p))}})):"ppcp-gateway"===cartflows_offer.payment_method?(w=t,cartflows_offer.payment_method,w.action="wcf_create_paypal_payments_order",w._nonce=cartflows_offer.wcf_create_paypal_order_nonce,m.ajax({url:cartflows.ajax_url,data:w,dataType:"json",type:"POST",success(e){"success"===e.status?window.location.href=e.redirect:(w.action="wcf_"+w.offer_type+"_accepted",u(w))}})):"cpsw_stripe"===cartflows_offer.payment_method||"cpsw_stripe_element"===cartflows_offer.payment_method?("cpsw_stripe"===cartflows_offer.payment_method?(t.action="wcf_cpsw_create_payment_intent",t._nonce=cartflows_offer.wcf_cpsw_create_payment_intent_nonce):(t.action="wcf_cpsw_create_payment_element_intent",t._nonce=cartflows_offer.wcf_cpsw_create_payment_element_intent_nonce),m.ajax({url:cartflows.ajax_url,data:t,dataType:"json",type:"POST",success(e){e.hasOwnProperty("client_secret")&&""!==e.client_secret?Stripe(e.cpsw_pk).confirmCardPayment(e.client_secret).then(function(e){if(e.error)throw e.error;"requires_capture"!==e.paymentIntent.status&&"succeeded"!==e.paymentIntent.status||(t.action=action,t.cpsw_intent_id=e.paymentIntent.id,t.cpsw_payment_method=e.paymentIntent.payment_method,u(t))}).catch(function(){window.location.reload()}):(t.action=action,u(t))}})):"woocommerce_payments"===cartflows_offer.payment_method?(t.action="wcf_woop_create_payment_intent",t.wcf_wc_payment_nonce=cartflows_offer.wcf_woop_create_payment_intent_nonce,m.ajax({url:cartflows.ajax_url,data:t,dataType:"json",type:"POST",success(e){e.hasOwnProperty("client_secret")&&""!==e.client_secret&&"succeeded"!==e.status?Stripe(e.client_public).confirmCardPayment(e.client_secret).then(function(e){if(e.error)throw e.error;"requires_capture"!==e.paymentIntent.status&&"succeeded"!==e.paymentIntent.status||(t.action=action,t.woop_intent_id=e.paymentIntent.id,t.woop_payment_method=e.paymentIntent.payment_method,u(t))}).catch(function(){window.location.reload()}):(t.action=action,t.woop_intent_id=e.client_intend,u(t))}})):"cppw_paypal"===cartflows_offer.payment_method?(t.action="wcf_cppw_create_paypal_order",t._nonce=cartflows_offer.wcf_cppw_create_paypal_order_nonce,m.ajax({url:cartflows.ajax_url,data:t,dataType:"json",type:"POST",success(e){"succeeded"===e.status?(t.action=action,t.transaction_id=e.transaction_id):t.action=action,u(t)}})):(t.action=action,u(t)):(t.action=action,u(t)),!1}}})}function t(){var e=jQuery(".woocommerce-product-gallery");if(0<e.length&&1<=e.find(".woocommerce-product-gallery__image").length){let e=jQuery(".woocommerce-product-gallery").flexslider({animation:"slide",animationLoop:!1,controlNav:"thumbnails",selector:".slides .woocommerce-product-gallery__image",directionNav:!1}),i=(m(window).on("load",function(){e.trigger("resize")}),m(".variations_form"));if(0<i.length){let a=function(o){let e=i,t=m(".woocommerce-product-gallery"),a=t.find(".flex-control-nav");if(o&&o.image&&o.image.src&&1<o.image.src.length){0<a.find('li img[data-o_src="'+o.image.gallery_thumbnail_src+'"]').length&&c();var r=a.find('li img[src="'+o.image.gallery_thumbnail_src+'"]');if(0<r.length)return r.trigger("click"),e.attr("current-image",o.image_id),void window.setTimeout(function(){m(window).trigger("resize"),t.trigger("woocommerce_gallery_init_zoom")},20);var r=t.find(".woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder").eq(0),n=r.find(".wp-post-image"),_=r.find("a").eq(0);n.wc_set_variation_attr("src",o.image.src),n.wc_set_variation_attr("height",o.image.src_h),n.wc_set_variation_attr("width",o.image.src_w),n.wc_set_variation_attr("srcset",o.image.srcset),n.wc_set_variation_attr("sizes",o.image.sizes),n.wc_set_variation_attr("title",o.image.title),n.wc_set_variation_attr("data-caption",o.image.caption),n.wc_set_variation_attr("alt",o.image.alt),n.wc_set_variation_attr("data-src",o.image.full_src),n.wc_set_variation_attr("data-large_image",o.image.full_src),n.wc_set_variation_attr("data-large_image_width",o.image.full_src_w),n.wc_set_variation_attr("data-large_image_height",o.image.full_src_h),r.wc_set_variation_attr("data-thumb",o.image.src),a.find("li:eq(0) img").wc_set_variation_attr("src",o.image.gallery_thumbnail_src),_.wc_set_variation_attr("href",o.image.full_src)}else c();window.setTimeout(function(){m(window).trigger("resize");{var t=o,a=i,r=m(".woocommerce-product-gallery"),t=t&&t.image_id?t.image_id:"";let e=!1;a.attr("current-image")!==t&&(e=!0),a.attr("current-image",t),e&&r.flexslider(0)}},20)},c=function(){var e=m(".woocommerce-product-gallery"),t=e.find(".flex-control-nav").find("li:eq(0) img"),e=e.find(".woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder").eq(0),a=e.find(".wp-post-image"),r=e.find("a").eq(0);a.wc_reset_variation_attr("src"),a.wc_reset_variation_attr("width"),a.wc_reset_variation_attr("height"),a.wc_reset_variation_attr("srcset"),a.wc_reset_variation_attr("sizes"),a.wc_reset_variation_attr("title"),a.wc_reset_variation_attr("data-caption"),a.wc_reset_variation_attr("alt"),a.wc_reset_variation_attr("data-src"),a.wc_reset_variation_attr("data-large_image"),a.wc_reset_variation_attr("data-large_image_width"),a.wc_reset_variation_attr("data-large_image_height"),e.wc_reset_variation_attr("data-thumb"),t.wc_reset_variation_attr("src"),r.wc_reset_variation_attr("href")};m(".variations_form").on("found_variation",function(e,t){a(t)})}}}function a(){0<m(".wcf-offer-product-quantity").length&&m(".wcf-offer-product-quantity .qty").on("change",function(){var e=m(this).val();m(".wcf-offer-product-quantity .qty").val(e)}),0<m(".wcf-offer-product-variation .variations select").length?(m(".wcf-variable-price-range").show().siblings().remove(),m(".wcf-offer-product-variation .variations select").on("change",function(){var t=m(this),a=t.data("attribute_name");if(0!==t.length){let e=t.val();m('.wcf-offer-product-variation [data-attribute_name ="'+a+'"]').each(function(){m(this).val(e),""===e||0===e?m(this).addClass("var_not_selected"):m(this).removeClass("var_not_selected")})}}),m(".variations_form").on("found_variation",function(e,t){var a=cartflows_offer.discount_type,r=cartflows_offer.discount_value,o=cartflows_offer.currency_symbol,n=t.display_price;let _=t.display_price,c=(0<r&&("discount_percent"===a?_-=_*r/100:"discount_price"===a&&(_-=r)),'<span class="wcf-single-variation-price">');c=n!==_?(c=(c=(c+='<span class="wcf-regular-price del">')+(o+n.toFixed(2)))+'</span><span class="wcf-discount-price">')+(o+_.toFixed(2))+"</span>":(c+='<span class="wcf-regular-price">')+(o+n.toFixed(2))+"</span>",c+="</span>",m(".wcf-offer-price").html(c)})):(m(".wcf-variable-price-range").remove(),m(".wcf-offer-price-inner").show()),t()}let o={getUrlParameter(e){var t=decodeURIComponent(window.location.search.substring(1)).split("&");let a,r;for(r=0;r<t.length;r++)if((a=t[r].split("="))[0]===e)return void 0===a[1]||a[1]},is_doing_offer_ajax:!1},n=function(e){var t;e.offer_action&&(t={action:e.action,flow_id:e.flow_id,input_qty:e.input_qty,offer_action:e.offer_action,offer_type:e.offer_type,order_id:e.order_id,product_id:e.product_id,step_id:e.step_id,variation_id:e.variation_id},document.dispatchEvent(new CustomEvent(e.action,{bubbles:!0,detail:t})))},u=function(r){r._nonce=cartflows_offer[r.action+"_nonce"],o.is_doing_offer_ajax||(o.is_doing_offer_ajax=!0,m.ajax({url:cartflows.ajax_url,data:r,dataType:"json",type:"POST",success(e){var t=e.message,a="wcf-payment-"+e.status;n(r),m("body").trigger("wcf-update-msg",[t,a]),o.is_doing_offer_ajax=!1,setTimeout(function(){window.location.href=e.redirect},600)}}))};m(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/offer-product-image.default",t)}),m(function(){if(m("body").on("wcf-show-loader",function(e,t){"no"===t&&(jQuery(".wcf-note-yes").hide(),jQuery(".wcf-note-no").show(),jQuery(".wcf-process-msg").hide()),m(".wcf-loader-bg").addClass("show")}),m("body").on("wcf-hide-loader",function(){m(".wcf-loader-bg").removeClass("show")}),m("body").on("wcf-update-msg",function(e,t,a){m(".wcf-order-msg .wcf-process-msg").text(t).addClass(a).show()}),e(),a(),"1"!==cartflows.is_pb_preview&&(jQuery(document).ajaxComplete(function(e,t){t.hasOwnProperty("responseJSON")&&((t=t.responseJSON.hasOwnProperty("fragments")?t.responseJSON.fragments:null)&&t.hasOwnProperty("added_to_cart_data")&&fbq("track","AddToCart",t.added_to_cart_data.added_to_cart),"enable"===cartflows.fb_setting.facebook_pixel_add_payment_info)&&t&&t.hasOwnProperty("fb_add_payment_info_data")&&(cartflows.fb_add_payment_info_data=t.fb_add_payment_info_data)}),jQuery(document).ajaxComplete(function(e,t){t.hasOwnProperty("responseJSON")&&((t=t.responseJSON.hasOwnProperty("fragments")?t.responseJSON.fragments:null)&&t.hasOwnProperty("tiktok_added_to_cart_data")&&ttq.track("AddToCart",t.tiktok_added_to_cart_data?.added_to_cart),"enable"===cartflows.tik_setting?.enable_tiktok_add_payment_info)&&t&&t.hasOwnProperty("tiktok_add_payment_info_data")&&(cartflows.tiktok_add_payment_info_data=t.tiktok_add_payment_info_data)}),jQuery(document).ajaxComplete(function(e,t,a){var r,o;t.hasOwnProperty("responseJSON")&&(r=(o=cartflows.ga_setting).enable_add_to_cart,o=o.enable_add_payment_info,cartflows.is_checkout_page)&&(t=t.responseJSON.hasOwnProperty("fragments")?t.responseJSON.fragments:null,a.hasOwnProperty("data"))&&-1!==a.data.indexOf("action=wcf_bump_order_process")&&("enable"===r&&(t&&t.hasOwnProperty("ga_added_to_cart_data")&>ag("event","add_to_cart",JSON.parse(t.ga_added_to_cart_data.add_to_cart)),t)&&t.hasOwnProperty("ga_remove_to_cart_data")&>ag("event","remove_from_cart",JSON.parse(t.ga_remove_to_cart_data.remove_from_cart)),"enable"===o)&&t&&t.hasOwnProperty("ga_add_payment_info_data")&&(cartflows.add_payment_info_data=t.ga_add_payment_info_data)}),jQuery(document).ajaxComplete(function(e,t){t.hasOwnProperty("responseJSON")&&(t=t.responseJSON.hasOwnProperty("fragments")?t.responseJSON.fragments:null,"undefined"!=typeof pintrk&&t&&t.hasOwnProperty("pinterest_added_to_cart_data")&&pintrk("track","AddToCart",t.pinterest_added_to_cart_data?.added_to_cart),"enable"===cartflows.pinterest_setting?.enable_pinterest_add_payment_info)&&t&&t.hasOwnProperty("pinterest_add_payment_info_data")&&(cartflows.pinterest_add_payment_info_data=t.pinterest_add_payment_info_data)}),jQuery(document).ajaxComplete(function(e,t,a){var r,o;t.hasOwnProperty("responseJSON")&&(r=(o=cartflows?.gads_setting)?.enable_google_ads_add_to_cart,o=o?.enable_google_ads_add_payment_info,cartflows?.is_checkout_page)&&(t=t.responseJSON.hasOwnProperty("fragments")?t.responseJSON.fragments:null,a.hasOwnProperty("data"))&&-1!==a.data.indexOf("action=wcf_bump_order_process")&&("enable"===r&&(t&&t.hasOwnProperty("gads_added_to_cart_data")&>ag("event","add_to_cart",JSON.parse(t.gads_added_to_cart_data.add_to_cart)),t)&&t.hasOwnProperty("gads_remove_to_cart_data")&>ag("event","remove_from_cart",JSON.parse(t.gads_remove_to_cart_data.remove_from_cart)),"enable"===o)&&t&&t.hasOwnProperty("gads_add_payment_info_data")&&(cartflows.add_payment_info_data=t.gads_add_payment_info_data)}),jQuery(document).ajaxComplete(function(e,t){t.hasOwnProperty("responseJSON")&&(t=t.responseJSON.hasOwnProperty("fragments")?t.responseJSON.fragments:null)&&t.hasOwnProperty("snapchat_added_to_cart_data")&&snaptr("track","ADD_CART",t.snapchat_added_to_cart_data?.added_to_cart)})),"undefined"!=typeof cartflows_offer){let e="";o.getUrlParameter("wcf-mollie-return")&&("mollie_wc_gateway_creditcard"===cartflows_offer.payment_method&&(e=cartflows_offer.wcf_mollie_creditcard_process_nonce),"mollie_wc_gateway_ideal"===cartflows_offer.payment_method&&(e=cartflows_offer.wcf_mollie_ideal_process_nonce),t={action:"wcf_"+(t=cartflows_offer.offer_type)+"_accepted",offer_action:"yes",offer_type:t,step_id:cartflows_offer.step_id,product_id:cartflows_offer.product_id,order_id:cartflows_offer.order_id,order_key:cartflows_offer.order_key,flow_id:cartflows.current_flow,stripe_sca_payment:!1,stripe_intent_id:"",_nonce:e},u(t))}if("undefined"!=typeof cartflows_offer){var t=o.getUrlParameter("wcf-ppcp-return");let a;t&&(a=cartflows_offer.wcf_capture_paypal_order_nonce,t={action:"wcf_capture_paypal_order",step_id:cartflows_offer.step_id,order_id:cartflows_offer.order_id,_nonce:a},m("body").trigger("wcf-show-loader","yes"),m.ajax({url:cartflows.ajax_url,data:t,dataType:"json",type:"POST",success(t){if("success"===t.status){t=cartflows_offer.offer_type;let e={action:"wcf_"+t+"_accepted",offer_action:"yes",offer_type:t,step_id:cartflows_offer.step_id,product_id:cartflows_offer.product_id,order_id:cartflows_offer.order_id,order_key:cartflows_offer.order_key,flow_id:cartflows.current_flow,stripe_sca_payment:!1,stripe_intent_id:"",_nonce:a};u(e)}else data.action=data.action="wcf_"+data.offer_type+"_accepted",u(data)}}))}})})(jQuery);