Fix GooglePay notice placement.

This commit is contained in:
Pedro Silva 2023-09-27 11:12:09 +01:00
parent 59219009c3
commit b96e556257
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 43 additions and 4 deletions

View file

@ -52,7 +52,9 @@ return array(
'googlepay.availability_notice' => static function ( ContainerInterface $container ): AvailabilityNotice { 'googlepay.availability_notice' => static function ( ContainerInterface $container ): AvailabilityNotice {
return new AvailabilityNotice( return new AvailabilityNotice(
$container->get( 'googlepay.helpers.apm-product-status' ) $container->get( 'googlepay.helpers.apm-product-status' ),
$container->get( 'wcgateway.is-wc-gateways-list-page' ),
$container->get( 'wcgateway.is-ppcp-settings-page' )
); );
}, },

View file

@ -24,13 +24,35 @@ class AvailabilityNotice {
*/ */
private $product_status; private $product_status;
/**
* Indicates if we're on the WooCommerce gateways list page.
*
* @var bool
*/
private $is_wc_gateways_list_page;
/**
* Indicates if we're on a PPCP Settings page.
*
* @var bool
*/
private $is_ppcp_settings_page;
/** /**
* Class ApmProductStatus constructor. * Class ApmProductStatus constructor.
* @param ApmProductStatus $product_status The product status handler. * @param ApmProductStatus $product_status The product status handler.
* @param bool $is_wc_gateways_list_page Indicates if we're on the WooCommerce gateways list page.
* @param bool $is_ppcp_settings_page Indicates if we're on a PPCP Settings page.
*/ */
public function __construct( ApmProductStatus $product_status ) { public function __construct(
$this->product_status = $product_status; ApmProductStatus $product_status,
bool $is_wc_gateways_list_page,
bool $is_ppcp_settings_page
) {
$this->product_status = $product_status;
$this->is_wc_gateways_list_page = $is_wc_gateways_list_page;
$this->is_ppcp_settings_page = $is_ppcp_settings_page;
} }
/** /**
@ -39,7 +61,7 @@ class AvailabilityNotice {
* @return void * @return void
*/ */
public function execute(): void { public function execute(): void {
if ( ! $this->product_status->is_onboarded() ) { if ( ! $this->should_display() ) {
return; return;
} }
@ -50,6 +72,21 @@ class AvailabilityNotice {
} }
} }
/**
* Whether the message should display.
*
* @return bool
*/
protected function should_display(): bool {
if ( ! $this->product_status->is_onboarded() ) {
return false;
}
if ( ! $this->is_wc_gateways_list_page && ! $this->is_ppcp_settings_page ) {
return false;
}
return true;
}
/** /**
* Adds seller status failure notice. * Adds seller status failure notice.
* *