From b1bfa2940b0414af8c19d55617da0b4eb92ec0f3 Mon Sep 17 00:00:00 2001 From: George Burduli Date: Wed, 29 May 2024 17:44:28 +0400 Subject: [PATCH 1/2] Disable Pay Upon Invoice if billing/shipping country not set --- modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php index 823caf611..c140b0976 100644 --- a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php +++ b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php @@ -57,13 +57,13 @@ class PayUponInvoiceHelper { // phpcs:ignore WordPress.Security.NonceVerification.Missing $billing_country = wc_clean( wp_unslash( $_POST['country'] ?? '' ) ); - if ( $billing_country && 'DE' !== $billing_country ) { + if ( empty( $billing_country ) || 'DE' !== $billing_country ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification.Missing $shipping_country = wc_clean( wp_unslash( $_POST['s_country'] ?? '' ) ); - if ( $shipping_country && 'DE' !== $shipping_country ) { + if ( empty( $shipping_country ) || 'DE' !== $shipping_country ) { return false; } From 4a3345113b554b28e399a57c4a7920b5bb80086f Mon Sep 17 00:00:00 2001 From: George Burduli Date: Fri, 31 May 2024 13:07:41 +0400 Subject: [PATCH 2/2] Use WC Customer API to retrieve billing and shipping countries --- modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php index c140b0976..b91eca8a0 100644 --- a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php +++ b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php @@ -56,13 +56,13 @@ class PayUponInvoiceHelper { } // phpcs:ignore WordPress.Security.NonceVerification.Missing - $billing_country = wc_clean( wp_unslash( $_POST['country'] ?? '' ) ); + $billing_country = WC()->customer->get_billing_country(); if ( empty( $billing_country ) || 'DE' !== $billing_country ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification.Missing - $shipping_country = wc_clean( wp_unslash( $_POST['s_country'] ?? '' ) ); + $shipping_country = WC()->customer->get_shipping_country(); if ( empty( $shipping_country ) || 'DE' !== $shipping_country ) { return false; }