mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Separate "module loaded" "block enabled" methods
This commit is contained in:
parent
71c0da5c35
commit
f2a741094c
1 changed files with 14 additions and 3 deletions
|
@ -15,6 +15,7 @@ use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
|||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\SettingsStatus;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
|
@ -22,16 +23,26 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
|||
*/
|
||||
class PayLaterBlockModule implements ModuleInterface {
|
||||
/**
|
||||
* Returns whether the block should be loaded.
|
||||
* Returns whether the block module should be loaded.
|
||||
*/
|
||||
public static function is_enabled(): bool {
|
||||
public static function is_module_loading_required(): bool {
|
||||
return apply_filters(
|
||||
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
'woocommerce.feature-flags.woocommerce_paypal_payments.paylater_block_enabled',
|
||||
getenv( 'PCP_PAYLATER_BLOCK' ) === '1'
|
||||
getenv( 'PCP_PAYLATER_BLOCK' ) !== '0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the block is enabled.
|
||||
*
|
||||
* @param SettingsStatus $settings_status The Settings status helper.
|
||||
* @return bool true if the block is enabled, otherwise false.
|
||||
*/
|
||||
public static function is_block_enabled( SettingsStatus $settings_status ): bool {
|
||||
return self::is_module_loading_required() && $settings_status->is_pay_later_messaging_enabled_for_location( 'product_preview' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue