diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php index 46423386f..ce48c9c06 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php @@ -589,23 +589,28 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) { return false; } } + $smart_cancel_page = ''; if(is_product() && $this->single_product_configure_settings) { $this->button_layout = $this->single_product_button_layout; $this->button_size = $this->single_product_button_size; $this->disallowed_funding_methods = $this->single_product_disallowed_funding_methods; + $smart_cancel_page = wc_get_cart_url(); } elseif(is_cart() && $this->cart_configure_settings) { $this->button_layout = $this->cart_button_layout; $this->button_size = $this->cart_button_size; $this->disallowed_funding_methods = $this->cart_disallowed_funding_methods; + $smart_cancel_page = wc_get_cart_url(); } elseif (is_checkout() && $this->checkout_page_configure_settings) { $this->button_layout = $this->checkout_page_button_layout; $this->button_size = $this->checkout_page_button_size; $this->disallowed_funding_methods = $this->checkout_page_disallowed_funding_methods; + $smart_cancel_page = wc_get_checkout_url(); } if($this->mini_cart_configure_settings == false) { $this->mini_cart_button_layout = $this->button_layout; $this->mini_cart_button_size = $this->button_size; $this->mini_cart_disallowed_funding_methods = $this->disallowed_funding_methods; + $smart_cancel_page = wc_get_cart_url(); } $this->mini_cart_allowed_funding_methods = $this->allowed_funding_methods; if($this->wsc_cart_configure_settings == false) { @@ -682,6 +687,7 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) { 'wsc_cart_button_size' => $this->wsc_cart_button_size, 'button_fundingicons' => $this->button_fundingicons, 'cancel_page' => add_query_arg('pp_action', 'cancel_order', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')), + 'smart_cancel_page' => $smart_cancel_page, 'is_paypal_credit_enable' => $this->is_paypal_credit_enable ? "yes" : 'no', 'allowed_funding_methods' => $allowed_funding_methods_json, 'disallowed_funding_methods' => $disallowed_funding_methods_json, diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php index 7483eb87c..32e454b41 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php @@ -103,11 +103,11 @@ public function angelleye_redirect() { if (wc_notice_count('error') > 0) { if($this->save_abandoned_checkout == true) { wp_send_json(array( - 'url' => get_permalink(wc_get_page_id('cart')) + 'url' => wc_get_cart_url() )); } else { return array( - 'url' => get_permalink(wc_get_page_id('cart')) + 'url' => wc_get_cart_url() ); } exit(); @@ -125,7 +125,7 @@ public function angelleye_redirect() { } } else { - wp_redirect(get_permalink(wc_get_page_id('cart'))); + wp_redirect(wc_get_cart_url()); exit; } } else { @@ -145,7 +145,7 @@ public function angelleye_redirect() { } else { $args = array( 'result' => 'failure', - 'redirect' => get_permalink(wc_get_page_id('cart')), + 'redirect' => wc_get_cart_url(), ); if ($this->function_helper->ec_is_version_gte_2_4()) { if (ob_get_length()) { @@ -634,7 +634,7 @@ public function angelleye_set_express_checkout_request() { $order = null; $cancel_url = !empty($this->gateway->cancel_page_id) ? get_permalink($this->gateway->cancel_page_id) : wc_get_cart_url(); if ($cancel_url == false) { - $cancel_url = wc_get_cart_url(); + $cancel_url = wc_get_checkout_url(); } $cancel_url = add_query_arg('utm_nooverride', '1', $cancel_url); $order_total = ''; diff --git a/assets/js/angelleye-in-context-checkout.js b/assets/js/angelleye-in-context-checkout.js index a2a560996..557bfabc1 100644 --- a/assets/js/angelleye-in-context-checkout.js +++ b/assets/js/angelleye-in-context-checkout.js @@ -104,7 +104,7 @@ jQuery(function ($) { }); }, onCancel: function (data, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; }, onClick: function () { if (angelleye_in_content_param.enable_google_analytics_click === 'yes') { @@ -120,7 +120,7 @@ jQuery(function ($) { onError: function (err, actions) { console.log("err"); if ($('.angelleye_button_single').length) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; } } }, '.angelleye_button_single'); @@ -206,7 +206,7 @@ jQuery(function ($) { }); }, onCancel: function (data, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; }, onClick: function () { if (angelleye_in_content_param.enable_google_analytics_click === 'yes') { @@ -220,7 +220,7 @@ jQuery(function ($) { } }, onError: function (err, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; } }, selector); } @@ -296,7 +296,7 @@ jQuery(function ($) { }); }, onCancel: function (data, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; }, onClick: function () { if (angelleye_in_content_param.enable_google_analytics_click === 'yes') { @@ -310,7 +310,7 @@ jQuery(function ($) { } }, onError: function (err, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; } }, selector); } @@ -383,7 +383,7 @@ jQuery(function ($) { }); }, onCancel: function (data, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; }, onClick: function () { if (angelleye_in_content_param.enable_google_analytics_click === 'yes') { @@ -397,7 +397,7 @@ jQuery(function ($) { } }, onError: function (err, actions) { - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; } }, selector); } @@ -477,7 +477,7 @@ jQuery(function ($) { }, onCancel: function (data, actions) { $('.woocommerce').unblock(); - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; }, onClick: function () { if (angelleye_in_content_param.enable_google_analytics_click === 'yes') { @@ -492,7 +492,7 @@ jQuery(function ($) { }, onError: function (err, actions) { $('.woocommerce').unblock(); - window.location.href = angelleye_in_content_param.cancel_page; + window.location.href = angelleye_in_content_param.smart_cancel_page; } }, selector); } diff --git a/assets/js/angelleye-in-context-checkout.min.js b/assets/js/angelleye-in-context-checkout.min.js index 98254c43d..27b57d256 100644 --- a/assets/js/angelleye-in-context-checkout.min.js +++ b/assets/js/angelleye-in-context-checkout.min.js @@ -1 +1 @@ -jQuery(function(e){if("undefined"==typeof angelleye_in_content_param)return!1;function n(){var n=angelleye_in_content_param.disallowed_funding_methods;return null===n&&(n=[]),!(e.inArray("card",n)>-1)}function t(){e(".angelleye_button_single").length>0&&(e(".angelleye_button_single").empty(),window.paypalCheckoutReady=function(){allowed_funding_methods_single_array=e.parseJSON(angelleye_in_content_param.allowed_funding_methods),disallowed_funding_methods_single_array=e.parseJSON(angelleye_in_content_param.disallowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&disallowed_funding_methods_single_array.push("credit");var t=function(){var n=e(".variations_form").find(".variations select"),t={},a=0,o=0;return n.each(function(){var n=e(this).data("attribute_name")||e(this).attr("name"),_=e(this).val()||"";_.length>0&&o++,a++,t[n]=_}),{count:a,chosenCount:o,data:t}};angelleye_cart_style_object={size:angelleye_in_content_param.button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},"horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),e(".angelleye_button_single").empty(),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:allowed_funding_methods_single_array,disallowed:disallowed_funding_methods_single_array},payment:function(n,a){var o,_={nonce:angelleye_in_content_param.generate_cart_nonce,qty:e(".quantity .qty").val(),attributes:e(".variations_form").length?JSON.stringify(t().data):[],is_cc:"",product_id:e("input[name=add-to-cart]").val(),variation_id:e("input[name=variation_id]").val(),request_from:"JSv4",express_checkout:"true"};return o=angelleye_in_content_param.add_to_cart_ajaxurl,e("#wc-paypal_express-new-payment-method").is(":checked")&&(o+="&ec_save_to_account=true"),paypal.request.post(o,_).then(function(e){return paypal.request.post(e.url,{request_from:"JSv4"}).then(function(e){return e.token})})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"button_click"})},onError:function(n,t){console.log("err"),e(".angelleye_button_single").length&&(window.location.href=angelleye_in_content_param.cancel_page)}},".angelleye_button_single")})}function a(){window.paypalCheckoutReady=function(){var t,a=[],o=[];"yes"==angelleye_in_content_param.is_checkout&&"yes"==angelleye_in_content_param.is_display_on_checkout&&a.push(".angelleye_smart_button_checkout_top"),"yes"==angelleye_in_content_param.is_cart&&("both"==angelleye_in_content_param.cart_button_possition?a.push(".angelleye_smart_button_top",".angelleye_smart_button_bottom"):"bottom"==angelleye_in_content_param.cart_button_possition?a.push(".angelleye_smart_button_bottom"):"top"==angelleye_in_content_param.cart_button_possition&&a.push(".angelleye_smart_button_top")),o=e.parseJSON(angelleye_in_content_param.disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){if(e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&("horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){var n;return n=angelleye_in_content_param.set_express_checkout,e("#wc-paypal_express-new-payment-method").is(":checked")?n+="&ec_save_to_account=true":e("#wc-paypal_express-new-payment-method_bottom").is(":checked")&&(n+="&ec_save_to_account=true"),paypal.request.post(n,{request_from:"JSv4"}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(e,n){window.location.href=angelleye_in_content_param.cancel_page}},a)),"angelleye_smart_button_checkout_top"===a)return!1})}}function o(){window.paypalCheckoutReady=function(){var t,a=[],o=[];a.push(".angelleye_smart_button_mini"),o=e.parseJSON(angelleye_in_content_param.mini_cart_disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.mini_cart_allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.mini_cart_button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.mini_cart_button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&(angelleye_cart_style_object.size="responsive","horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){var n;return n=angelleye_in_content_param.set_express_checkout,e("#wc-paypal_express-new-payment-method").is(":checked")&&(n+="&ec_save_to_account=true"),paypal.request.post(n,{request_from:"JSv4"}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(e,n){window.location.href=angelleye_in_content_param.cancel_page}},a))})}}function _(){window.paypalCheckoutReady=function(){var t,a=[],o=[];a.push(".angelleye_smart_button_wsc"),o=e.parseJSON(angelleye_in_content_param.wsc_cart_disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.wsc_cart_allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.wsc_cart_button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.wsc_cart_button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&(angelleye_cart_style_object.size="responsive","horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){var n;return n=angelleye_in_content_param.set_express_checkout,e("#wc-paypal_express-new-payment-method").is(":checked")&&(n+="&ec_save_to_account=true"),paypal.request.post(n,{request_from:"JSv4"}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(e,n){window.location.href=angelleye_in_content_param.cancel_page}},a))})}}if(a(),o(),t(),_(),e(document.body).on("cart_totals_refreshed updated_shipping_method wc_fragments_refreshed updated_checkout updated_wc_div updated_cart_totals wc_fragments_loaded",function(e){a()}),"no"===angelleye_in_content_param.checkout_page_disable_smart_button&&e(document.body).on("updated_shipping_method wc_fragments_refreshed updated_checkout",function(t){window.paypalCheckoutReady=function(){var t,a=[],o=[];a.push(".angelleye_smart_button_checkout_bottom"),o=e.parseJSON(angelleye_in_content_param.disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){if(e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&("horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){e(".woocommerce").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n=e(a).closest("form").add(e(' ').attr("value","JSv4")).add(e(' ').attr("value","yes")).serialize();return paypal.request({method:"post",url:angelleye_in_content_param.set_express_checkout,body:n}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(n,t){e(".woocommerce").unblock(),window.location.href=angelleye_in_content_param.cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(n,t){e(".woocommerce").unblock(),window.location.href=angelleye_in_content_param.cancel_page}},a)),"angelleye_smart_button_checkout_bottom"===a)return!1})}}),e(document.body).on("wc_fragments_loaded wc_fragments_refreshed",function(){var n=e(".angelleye_smart_button_mini");n.length&&(n.empty(),o());var a=e(".angelleye_button_single");a.length&&(a.empty(),t());var l=e(".angelleye_smart_button_wsc");l.length&&(l.empty(),_())}),"no"===angelleye_in_content_param.checkout_page_disable_smart_button){function l(){var n=e("#payment_method_paypal_express").is(":checked");e('input[name="wc-paypal_express-payment-token"]:checked').length>0?n&&e('input[name="wc-paypal_express-payment-token"]').length&&"new"===e('input[name="wc-paypal_express-payment-token"]:checked').val()?(e("#place_order").hide(),e(".angelleye_smart_button_checkout_bottom").show()):n&&e('input[name="wc-paypal_express-payment-token"]').length&&"new"!==e('input[name="wc-paypal_express-payment-token"]:checked').val()?(e("#place_order").show(),e(".angelleye_smart_button_checkout_bottom").hide()):n?(e(".angelleye_smart_button_checkout_bottom").show(),e("#place_order").hide()):(e(".angelleye_smart_button_checkout_bottom").hide(),e("#place_order").show()):n?(e(".angelleye_smart_button_checkout_bottom").show(),e("#place_order").hide()):(e(".angelleye_smart_button_checkout_bottom").hide(),e("#place_order").show())}e(document.body).on("updated_checkout wc-credit-card-form-init update_checkout",function(e){l()}),e("form.checkout").on("click",'input[name="payment_method"]',function(){l()}),e("form.checkout").on("click",'input[name="wc-paypal_express-payment-token"]',function(){"new"===e(this).val()?(e("#place_order").hide(),e(".angelleye_smart_button_checkout_bottom").show()):"new"!==e(this).val()&&(e("#place_order").show(),e(".angelleye_smart_button_checkout_bottom").hide())})}}); \ No newline at end of file +jQuery(function(e){if("undefined"==typeof angelleye_in_content_param)return!1;function n(){var n=angelleye_in_content_param.disallowed_funding_methods;return null===n&&(n=[]),!(e.inArray("card",n)>-1)}function t(){e(".angelleye_button_single").length>0&&(e(".angelleye_button_single").empty(),window.paypalCheckoutReady=function(){allowed_funding_methods_single_array=e.parseJSON(angelleye_in_content_param.allowed_funding_methods),disallowed_funding_methods_single_array=e.parseJSON(angelleye_in_content_param.disallowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&disallowed_funding_methods_single_array.push("credit");var t=function(){var n=e(".variations_form").find(".variations select"),t={},a=0,o=0;return n.each(function(){var n=e(this).data("attribute_name")||e(this).attr("name"),_=e(this).val()||"";_.length>0&&o++,a++,t[n]=_}),{count:a,chosenCount:o,data:t}};angelleye_cart_style_object={size:angelleye_in_content_param.button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},"horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),e(".angelleye_button_single").empty(),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:allowed_funding_methods_single_array,disallowed:disallowed_funding_methods_single_array},payment:function(n,a){var o,_={nonce:angelleye_in_content_param.generate_cart_nonce,qty:e(".quantity .qty").val(),attributes:e(".variations_form").length?JSON.stringify(t().data):[],is_cc:"",product_id:e("input[name=add-to-cart]").val(),variation_id:e("input[name=variation_id]").val(),request_from:"JSv4",express_checkout:"true"};return o=angelleye_in_content_param.add_to_cart_ajaxurl,e("#wc-paypal_express-new-payment-method").is(":checked")&&(o+="&ec_save_to_account=true"),paypal.request.post(o,_).then(function(e){return paypal.request.post(e.url,{request_from:"JSv4"}).then(function(e){return e.token})})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"button_click"})},onError:function(n,t){console.log("err"),e(".angelleye_button_single").length&&(window.location.href=angelleye_in_content_param.smart_cancel_page)}},".angelleye_button_single")})}function a(){window.paypalCheckoutReady=function(){var t,a=[],o=[];"yes"==angelleye_in_content_param.is_checkout&&"yes"==angelleye_in_content_param.is_display_on_checkout&&a.push(".angelleye_smart_button_checkout_top"),"yes"==angelleye_in_content_param.is_cart&&("both"==angelleye_in_content_param.cart_button_possition?a.push(".angelleye_smart_button_top",".angelleye_smart_button_bottom"):"bottom"==angelleye_in_content_param.cart_button_possition?a.push(".angelleye_smart_button_bottom"):"top"==angelleye_in_content_param.cart_button_possition&&a.push(".angelleye_smart_button_top")),o=e.parseJSON(angelleye_in_content_param.disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){if(e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&("horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){var n;return n=angelleye_in_content_param.set_express_checkout,e("#wc-paypal_express-new-payment-method").is(":checked")?n+="&ec_save_to_account=true":e("#wc-paypal_express-new-payment-method_bottom").is(":checked")&&(n+="&ec_save_to_account=true"),paypal.request.post(n,{request_from:"JSv4"}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page}},a)),"angelleye_smart_button_checkout_top"===a)return!1})}}function o(){window.paypalCheckoutReady=function(){var t,a=[],o=[];a.push(".angelleye_smart_button_mini"),o=e.parseJSON(angelleye_in_content_param.mini_cart_disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.mini_cart_allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.mini_cart_button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.mini_cart_button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&(angelleye_cart_style_object.size="responsive","horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){var n;return n=angelleye_in_content_param.set_express_checkout,e("#wc-paypal_express-new-payment-method").is(":checked")&&(n+="&ec_save_to_account=true"),paypal.request.post(n,{request_from:"JSv4"}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page}},a))})}}function _(){window.paypalCheckoutReady=function(){var t,a=[],o=[];a.push(".angelleye_smart_button_wsc"),o=e.parseJSON(angelleye_in_content_param.wsc_cart_disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.wsc_cart_allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.wsc_cart_button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.wsc_cart_button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&(angelleye_cart_style_object.size="responsive","horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){var n;return n=angelleye_in_content_param.set_express_checkout,e("#wc-paypal_express-new-payment-method").is(":checked")&&(n+="&ec_save_to_account=true"),paypal.request.post(n,{request_from:"JSv4"}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(e,n){window.location.href=angelleye_in_content_param.smart_cancel_page}},a))})}}if(a(),o(),t(),_(),e(document.body).on("cart_totals_refreshed updated_shipping_method wc_fragments_refreshed updated_checkout updated_wc_div updated_cart_totals wc_fragments_loaded",function(e){a()}),"no"===angelleye_in_content_param.checkout_page_disable_smart_button&&e(document.body).on("updated_shipping_method wc_fragments_refreshed updated_checkout",function(t){window.paypalCheckoutReady=function(){var t,a=[],o=[];a.push(".angelleye_smart_button_checkout_bottom"),o=e.parseJSON(angelleye_in_content_param.disallowed_funding_methods),t=e.parseJSON(angelleye_in_content_param.allowed_funding_methods),"no"==angelleye_in_content_param.is_paypal_credit_enable&&o.push("credit"),angelleye_cart_style_object={size:angelleye_in_content_param.button_size,color:angelleye_in_content_param.button_color,shape:angelleye_in_content_param.button_shape,label:angelleye_in_content_param.button_label,layout:angelleye_in_content_param.button_layout,tagline:"true"===angelleye_in_content_param.button_tagline},a.forEach(function(a){if(e(a).html(""),o=e.grep(o,function(e){return"venmo"!==e}),a.length>0&&e(a).length>0&&("horizontal"===angelleye_in_content_param.button_layout&&!0===n()&&"credit"!==angelleye_in_content_param.button_label&&"true"===angelleye_in_content_param.button_fundingicons&&(angelleye_cart_style_object.fundingicons="true"===angelleye_in_content_param.button_fundingicons),paypal.Button.render({env:angelleye_in_content_param.environment,style:angelleye_cart_style_object,locale:angelleye_in_content_param.locale,commit:"false"!==angelleye_in_content_param.zcommit,funding:{allowed:t,disallowed:o},payment:function(){e(".woocommerce").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n=e(a).closest("form").add(e(' ').attr("value","JSv4")).add(e(' ').attr("value","yes")).serialize();return paypal.request({method:"post",url:angelleye_in_content_param.set_express_checkout,body:n}).then(function(e){return e.token})},onAuthorize:function(e,n){var t={paymentToken:e.paymentToken,payerID:e.payerID,token:e.paymentToken,request_from:"JSv4"};paypal.request.post(e.returnUrl,t).then(function(t){e.returnUrl=t.url,n.redirect()})},onCancel:function(n,t){e(".woocommerce").unblock(),window.location.href=angelleye_in_content_param.smart_cancel_page},onClick:function(){"yes"===angelleye_in_content_param.enable_google_analytics_click&&"undefined"!=typeof ga&&e.isFunction(ga)&&ga("send",{hitType:"event",eventCategory:"Checkout",eventAction:"paypal_button_click"})},onError:function(n,t){e(".woocommerce").unblock(),window.location.href=angelleye_in_content_param.smart_cancel_page}},a)),"angelleye_smart_button_checkout_bottom"===a)return!1})}}),e(document.body).on("wc_fragments_loaded wc_fragments_refreshed",function(){var n=e(".angelleye_smart_button_mini");n.length&&(n.empty(),o());var a=e(".angelleye_button_single");a.length&&(a.empty(),t());var l=e(".angelleye_smart_button_wsc");l.length&&(l.empty(),_())}),"no"===angelleye_in_content_param.checkout_page_disable_smart_button){function l(){var n=e("#payment_method_paypal_express").is(":checked");e('input[name="wc-paypal_express-payment-token"]:checked').length>0?n&&e('input[name="wc-paypal_express-payment-token"]').length&&"new"===e('input[name="wc-paypal_express-payment-token"]:checked').val()?(e("#place_order").hide(),e(".angelleye_smart_button_checkout_bottom").show()):n&&e('input[name="wc-paypal_express-payment-token"]').length&&"new"!==e('input[name="wc-paypal_express-payment-token"]:checked').val()?(e("#place_order").show(),e(".angelleye_smart_button_checkout_bottom").hide()):n?(e(".angelleye_smart_button_checkout_bottom").show(),e("#place_order").hide()):(e(".angelleye_smart_button_checkout_bottom").hide(),e("#place_order").show()):n?(e(".angelleye_smart_button_checkout_bottom").show(),e("#place_order").hide()):(e(".angelleye_smart_button_checkout_bottom").hide(),e("#place_order").show())}e(document.body).on("updated_checkout wc-credit-card-form-init update_checkout",function(e){l()}),e("form.checkout").on("click",'input[name="payment_method"]',function(){l()}),e("form.checkout").on("click",'input[name="wc-paypal_express-payment-token"]',function(){"new"===e(this).val()?(e("#place_order").hide(),e(".angelleye_smart_button_checkout_bottom").show()):"new"!==e(this).val()&&(e("#place_order").show(),e(".angelleye_smart_button_checkout_bottom").hide())})}}); \ No newline at end of file diff --git a/classes/wc-gateway-paypal-express-angelleye.php b/classes/wc-gateway-paypal-express-angelleye.php index 6b849d100..23724b643 100644 --- a/classes/wc-gateway-paypal-express-angelleye.php +++ b/classes/wc-gateway-paypal-express-angelleye.php @@ -1631,7 +1631,7 @@ public function process_payment($order_id) { 'redirect' => add_query_arg( 'utm_nooverride', '1', $this->get_return_url($order) ) ); } else { - $redirect_url = get_permalink(wc_get_page_id('cart')); + $redirect_url = wc_get_cart_url(); $this->paypal_express_checkout_error_handler($request_name = 'DoReferenceTransaction', $redirect_url, $result); if (!is_ajax()) { wp_redirect($redirect_url); @@ -2217,7 +2217,7 @@ public function angelleye_check_cart_items() { } if( wc_notice_count( 'error' ) > 0 ) { self::log(print_r(wc_get_notices(), true)); - $redirect_url = get_permalink(wc_get_page_id('cart')); + $redirect_url = wc_get_cart_url(); wp_redirect($redirect_url); exit(); } @@ -2330,7 +2330,7 @@ public function angelleye_paypal_express_checkout_redirect_to_paypal($data, $err if($notice_count > 0) { if ( isset( $_POST['from_checkout'] ) && 'yes' === $_POST['from_checkout'] ) { wp_send_json(array( - 'url' => get_permalink(wc_get_page_id('checkout')) + 'url' => wc_get_checkout_url() )); exit(); } diff --git a/paypal-for-woocommerce.php b/paypal-for-woocommerce.php index 430fe789d..0ba1e5268 100644 --- a/paypal-for-woocommerce.php +++ b/paypal-for-woocommerce.php @@ -590,7 +590,7 @@ public static function angelleye_paypal_for_woocommerce_curl_error_handler($PayP wc_add_notice($display_error, 'error'); if (!is_ajax()) { if($redirect_url == null) { - wp_redirect(get_permalink(wc_get_page_id('cart'))); + wp_redirect(wc_get_cart_url()); } else { wp_redirect($redirect_url); }