Skip to content

Commit d516811

Browse files
committed
♻️ Consolidate country-based validation issues
1 parent bfeb693 commit d516811

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

modules/ppcp-store-sync/src/CartValidation/ShippingValidator.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class ShippingValidator implements ValidatorInterface {
3535
/**
3636
* List of shipping countries that are supported by the agentic integration.
3737
* Managed on plugin-side for extra code and test stability.
38-
*
39-
* If this list is expanded, also update the message in {@see validate_country()}
4038
*/
4139
private const PAYPAL_SUPPORTED_COUNTRIES = array( 'US' );
4240

@@ -348,17 +346,6 @@ private function validate_country( ?string $country_code ): ?ValidationIssue {
348346
);
349347
}
350348

351-
if ( $this->get_wc_countries() && ! $this->is_paypal_supported_country( $country_code ) ) {
352-
return ValidationIssue::create_shipping_unavailable( sprintf( 'Shipping to %s is not supported by PayPal', $country_code ) )
353-
->user_message( 'PayPal currently only supports shipping to the United States.' )
354-
->for_field( 'shipping_address.country_code' )
355-
->add_resolution(
356-
ResolutionOption::create_update_address()
357-
->label( 'Use a supported shipping country' )
358-
->priority( Priority::HIGH )
359-
);
360-
}
361-
362349
return null;
363350
}
364351

@@ -374,6 +361,10 @@ private function is_country_allowed( string $country_code ): bool {
374361
return true;
375362
}
376363

364+
if ( ! $this->is_paypal_supported_country( $country_code ) ) {
365+
return false;
366+
}
367+
377368
$allowed_countries = $wc_countries->get_shipping_countries();
378369

379370
if ( empty( $allowed_countries ) ) {

0 commit comments

Comments
 (0)