mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Omit shipping because of missing postal code only if country requires it
This commit is contained in:
parent
23e68419f8
commit
d5e543f72f
1 changed files with 4 additions and 8 deletions
|
@ -112,7 +112,7 @@ class PurchaseUnitFactory {
|
||||||
if (
|
if (
|
||||||
! $this->shipping_needed( ... array_values( $items ) ) ||
|
! $this->shipping_needed( ... array_values( $items ) ) ||
|
||||||
empty( $shipping->address()->country_code() ) ||
|
empty( $shipping->address()->country_code() ) ||
|
||||||
( $shipping->address()->country_code() && ! $shipping->address()->postal_code() )
|
( ! $shipping->address()->postal_code() && ! $this->country_without_postal_code( $shipping->address()->country_code() ) )
|
||||||
) {
|
) {
|
||||||
$shipping = null;
|
$shipping = null;
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,8 @@ class PurchaseUnitFactory {
|
||||||
if ( $this->shipping_needed( ... array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) {
|
if ( $this->shipping_needed( ... array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) {
|
||||||
$shipping = $this->shipping_factory->from_wc_customer( \WC()->customer );
|
$shipping = $this->shipping_factory->from_wc_customer( \WC()->customer );
|
||||||
if (
|
if (
|
||||||
2 !== strlen( $shipping->address()->country_code() )
|
2 !== strlen( $shipping->address()->country_code() ) ||
|
||||||
|| ( ! $shipping->address()->postal_code() )
|
( ! $shipping->address()->postal_code() && ! $this->country_without_postal_code( $shipping->address()->country_code() ) )
|
||||||
|| $this->country_without_postal_code( $shipping->address()->country_code() )
|
|
||||||
) {
|
) {
|
||||||
$shipping = null;
|
$shipping = null;
|
||||||
}
|
}
|
||||||
|
@ -275,9 +274,6 @@ class PurchaseUnitFactory {
|
||||||
*/
|
*/
|
||||||
private function country_without_postal_code( string $country_code ): bool {
|
private function country_without_postal_code( string $country_code ): bool {
|
||||||
$countries = array( 'AE', 'AF', 'AG', 'AI', 'AL', 'AN', 'AO', 'AW', 'BB', 'BF', 'BH', 'BI', 'BJ', 'BM', 'BO', 'BS', 'BT', 'BW', 'BZ', 'CD', 'CF', 'CG', 'CI', 'CK', 'CL', 'CM', 'CO', 'CR', 'CV', 'DJ', 'DM', 'DO', 'EC', 'EG', 'ER', 'ET', 'FJ', 'FK', 'GA', 'GD', 'GH', 'GI', 'GM', 'GN', 'GQ', 'GT', 'GW', 'GY', 'HK', 'HN', 'HT', 'IE', 'IQ', 'IR', 'JM', 'JO', 'KE', 'KH', 'KI', 'KM', 'KN', 'KP', 'KW', 'KY', 'LA', 'LB', 'LC', 'LK', 'LR', 'LS', 'LY', 'ML', 'MM', 'MO', 'MR', 'MS', 'MT', 'MU', 'MW', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NP', 'NR', 'NU', 'OM', 'PA', 'PE', 'PF', 'PY', 'QA', 'RW', 'SA', 'SB', 'SC', 'SD', 'SL', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SY', 'TC', 'TD', 'TG', 'TL', 'TO', 'TT', 'TV', 'TZ', 'UG', 'UY', 'VC', 'VE', 'VG', 'VN', 'VU', 'WS', 'XA', 'XB', 'XC', 'XE', 'XL', 'XM', 'XN', 'XS', 'YE', 'ZM', 'ZW' );
|
$countries = array( 'AE', 'AF', 'AG', 'AI', 'AL', 'AN', 'AO', 'AW', 'BB', 'BF', 'BH', 'BI', 'BJ', 'BM', 'BO', 'BS', 'BT', 'BW', 'BZ', 'CD', 'CF', 'CG', 'CI', 'CK', 'CL', 'CM', 'CO', 'CR', 'CV', 'DJ', 'DM', 'DO', 'EC', 'EG', 'ER', 'ET', 'FJ', 'FK', 'GA', 'GD', 'GH', 'GI', 'GM', 'GN', 'GQ', 'GT', 'GW', 'GY', 'HK', 'HN', 'HT', 'IE', 'IQ', 'IR', 'JM', 'JO', 'KE', 'KH', 'KI', 'KM', 'KN', 'KP', 'KW', 'KY', 'LA', 'LB', 'LC', 'LK', 'LR', 'LS', 'LY', 'ML', 'MM', 'MO', 'MR', 'MS', 'MT', 'MU', 'MW', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NP', 'NR', 'NU', 'OM', 'PA', 'PE', 'PF', 'PY', 'QA', 'RW', 'SA', 'SB', 'SC', 'SD', 'SL', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SY', 'TC', 'TD', 'TG', 'TL', 'TO', 'TT', 'TV', 'TZ', 'UG', 'UY', 'VC', 'VE', 'VG', 'VN', 'VU', 'WS', 'XA', 'XB', 'XC', 'XE', 'XL', 'XM', 'XN', 'XS', 'YE', 'ZM', 'ZW' );
|
||||||
if ( in_array( $country_code, $countries, true ) ) {
|
return in_array( $country_code, $countries, true );
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue