mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Allow to override the list of Pay Later supported countries
This commit is contained in:
parent
796ded031e
commit
381041138c
3 changed files with 24 additions and 14 deletions
|
@ -1642,6 +1642,21 @@ return array(
|
||||||
'SE',
|
'SE',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'api.paylater-countries' => static function ( ContainerInterface $container ) : array {
|
||||||
|
return apply_filters(
|
||||||
|
'woocommerce_paypal_payments_supported_paylater_countries',
|
||||||
|
array(
|
||||||
|
'US',
|
||||||
|
'DE',
|
||||||
|
'GB',
|
||||||
|
'FR',
|
||||||
|
'AU',
|
||||||
|
'IT',
|
||||||
|
'ES',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
'api.order-helper' => static function( ContainerInterface $container ): OrderHelper {
|
'api.order-helper' => static function( ContainerInterface $container ): OrderHelper {
|
||||||
return new OrderHelper();
|
return new OrderHelper();
|
||||||
},
|
},
|
||||||
|
|
|
@ -320,6 +320,7 @@ return array(
|
||||||
},
|
},
|
||||||
'button.helper.messages-apply' => static function ( ContainerInterface $container ): MessagesApply {
|
'button.helper.messages-apply' => static function ( ContainerInterface $container ): MessagesApply {
|
||||||
return new MessagesApply(
|
return new MessagesApply(
|
||||||
|
$container->get( 'api.paylater-countries' ),
|
||||||
$container->get( 'api.shop.country' )
|
$container->get( 'api.shop.country' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,17 +18,9 @@ class MessagesApply {
|
||||||
/**
|
/**
|
||||||
* In which countries credit messaging is available.
|
* In which countries credit messaging is available.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private $countries = array(
|
private $allowed_countries;
|
||||||
'US',
|
|
||||||
'DE',
|
|
||||||
'GB',
|
|
||||||
'FR',
|
|
||||||
'AU',
|
|
||||||
'IT',
|
|
||||||
'ES',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2-letter country code of the shop.
|
* 2-letter country code of the shop.
|
||||||
|
@ -40,10 +32,12 @@ class MessagesApply {
|
||||||
/**
|
/**
|
||||||
* MessagesApply constructor.
|
* MessagesApply constructor.
|
||||||
*
|
*
|
||||||
* @param string $country 2-letter country code of the shop.
|
* @param string[] $allowed_countries In which countries credit messaging is available.
|
||||||
|
* @param string $country 2-letter country code of the shop.
|
||||||
*/
|
*/
|
||||||
public function __construct( string $country ) {
|
public function __construct( array $allowed_countries, string $country ) {
|
||||||
$this->country = $country;
|
$this->allowed_countries = $allowed_countries;
|
||||||
|
$this->country = $country;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,6 +46,6 @@ class MessagesApply {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function for_country(): bool {
|
public function for_country(): bool {
|
||||||
return in_array( $this->country, $this->countries, true );
|
return in_array( $this->country, $this->allowed_countries, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue