mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Show notice only on ppcp and payments page
This commit is contained in:
parent
9408d1a9e5
commit
34ae2ee30b
2 changed files with 30 additions and 4 deletions
|
@ -143,7 +143,9 @@ return array(
|
|||
'wcgateway.notice.dcc-without-paypal' => static function ( $container ): DccWithoutPayPalAdminNotice {
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
return new DccWithoutPayPalAdminNotice( $state, $settings );
|
||||
$is_payments_page = $container->get( 'wcgateway.is-wc-payments-page' );
|
||||
$is_ppcp_settings_page = $container->get( 'wcgateway.is-ppcp-settings-page' );
|
||||
return new DccWithoutPayPalAdminNotice( $state, $settings, $is_payments_page, $is_ppcp_settings_page );
|
||||
},
|
||||
'wcgateway.notice.authorize-order-action' =>
|
||||
static function ( $container ): AuthorizeOrderActionNotice {
|
||||
|
|
|
@ -32,15 +32,38 @@ class DccWithoutPayPalAdminNotice {
|
|||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* Whether the current page is the WC payment page.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $is_payments_page;
|
||||
|
||||
/**
|
||||
* Whether the current page is the PPCP settings page.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $is_ppcp_settings_page;
|
||||
|
||||
/**
|
||||
* ConnectAdminNotice constructor.
|
||||
*
|
||||
* @param State $state The state.
|
||||
* @param ContainerInterface $settings The settings.
|
||||
* @param bool $is_payments_page Whether the current page is the WC payment page.
|
||||
* @param bool $is_ppcp_settings_page Whether the current page is the PPCP settings page.
|
||||
*/
|
||||
public function __construct( State $state, ContainerInterface $settings ) {
|
||||
public function __construct(
|
||||
State $state,
|
||||
ContainerInterface $settings,
|
||||
bool $is_payments_page,
|
||||
bool $is_ppcp_settings_page
|
||||
) {
|
||||
$this->state = $state;
|
||||
$this->settings = $settings;
|
||||
$this->is_payments_page = $is_payments_page;
|
||||
$this->is_ppcp_settings_page = $is_ppcp_settings_page;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,6 +94,7 @@ class DccWithoutPayPalAdminNotice {
|
|||
*/
|
||||
protected function should_display(): bool {
|
||||
return State::STATE_ONBOARDED === $this->state->current_state()
|
||||
&& ( $this->is_payments_page || $this->is_ppcp_settings_page )
|
||||
&& ( $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' ) )
|
||||
&& ( ! $this->settings->has( 'enabled' ) || ! $this->settings->get( 'enabled' ) );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue