mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Disable funding soures for Pay Later preview
This commit is contained in:
parent
7051e86003
commit
2775f7dd9d
4 changed files with 22 additions and 3 deletions
|
@ -64,6 +64,7 @@ import MessageRenderer from "../../../ppcp-button/resources/js/modules/Renderer/
|
|||
const disableFundingInput = jQuery('[name="ppcp[disable_funding][]"]');
|
||||
let disabledSources = disableFundingInput.length > 0 ? disableFundingInput.val() : PayPalCommerceGatewaySettings.disabled_sources;
|
||||
const isPayLaterButtonEnabled = payLaterButtonInput ? payLaterButtonInput.checked : PayPalCommerceGatewaySettings.is_pay_later_button_enabled
|
||||
const payLaterButtonPreview = jQuery('#ppcpPayLaterButtonPreview');
|
||||
const settings = {
|
||||
'client-id': PayPalCommerceGatewaySettings.client_id,
|
||||
'currency': PayPalCommerceGatewaySettings.currency,
|
||||
|
@ -77,6 +78,10 @@ import MessageRenderer from "../../../ppcp-button/resources/js/modules/Renderer/
|
|||
disabledSources = disabledSources.concat('credit')
|
||||
}
|
||||
|
||||
if(payLaterButtonPreview?.length) {
|
||||
disabledSources = Object.keys(PayPalCommerceGatewaySettings.all_funding_sources);
|
||||
}
|
||||
|
||||
if (disabledSources?.length) {
|
||||
settings['disable-funding'] = disabledSources;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,13 @@ class SettingsPageAssets {
|
|||
*/
|
||||
protected $disabled_sources;
|
||||
|
||||
/**
|
||||
* The list of all existing funding sources.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $all_funding_sources;
|
||||
|
||||
/**
|
||||
* Assets constructor.
|
||||
*
|
||||
|
@ -83,6 +90,7 @@ class SettingsPageAssets {
|
|||
* @param string $country 2-letter country code of the shop.
|
||||
* @param bool $is_pay_later_button_enabled Whether Pay Later button is enabled either for checkout, cart or product page.
|
||||
* @param array $disabled_sources The list of disabled funding sources.
|
||||
* @param array $all_funding_sources The list of all existing funding sources.
|
||||
*/
|
||||
public function __construct(
|
||||
string $module_url,
|
||||
|
@ -92,7 +100,8 @@ class SettingsPageAssets {
|
|||
string $currency,
|
||||
string $country,
|
||||
bool $is_pay_later_button_enabled,
|
||||
array $disabled_sources
|
||||
array $disabled_sources,
|
||||
array $all_funding_sources
|
||||
) {
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
|
@ -102,6 +111,7 @@ class SettingsPageAssets {
|
|||
$this->country = $country;
|
||||
$this->is_pay_later_button_enabled = $is_pay_later_button_enabled;
|
||||
$this->disabled_sources = $disabled_sources;
|
||||
$this->all_funding_sources = $all_funding_sources;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,6 +194,7 @@ class SettingsPageAssets {
|
|||
'integration_date' => PAYPAL_INTEGRATION_DATE,
|
||||
'is_pay_later_button_enabled' => $this->is_pay_later_button_enabled,
|
||||
'disabled_sources' => $this->disabled_sources,
|
||||
'all_funding_sources' => $this->all_funding_sources,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,8 @@ class WCGatewayModule implements ModuleInterface {
|
|||
$c->get( 'api.shop.currency' ),
|
||||
$c->get( 'api.shop.country' ),
|
||||
$settings_status->is_pay_later_button_enabled(),
|
||||
$settings->has( 'disable_funding' ) ? $settings->get( 'disable_funding' ) : array()
|
||||
$settings->has( 'disable_funding' ) ? $settings->get( 'disable_funding' ) : array(),
|
||||
$c->get( 'wcgateway.all-funding-sources' )
|
||||
);
|
||||
$assets->register_assets();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ class SettingsPagesAssetsTest extends TestCase
|
|||
'EUR',
|
||||
'DE',
|
||||
true,
|
||||
array());
|
||||
array(),
|
||||
array()
|
||||
);
|
||||
|
||||
when('is_admin')
|
||||
->justReturn(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue