mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #789 from woocommerce/pcp-703-hide-tabs-when-not-onboarded
Show tabs only after onboarding
This commit is contained in:
commit
33195d67df
2 changed files with 16 additions and 3 deletions
|
@ -200,7 +200,8 @@ return array(
|
|||
'wcgateway.settings.sections-renderer' => static function ( ContainerInterface $container ): SectionsRenderer {
|
||||
return new SectionsRenderer(
|
||||
$container->get( 'wcgateway.current-ppcp-settings-page-id' ),
|
||||
$container->get( 'wcgateway.settings.sections' )
|
||||
$container->get( 'wcgateway.settings.sections' ),
|
||||
$container->get( 'onboarding.state' )
|
||||
);
|
||||
},
|
||||
'wcgateway.settings.sections' => static function ( ContainerInterface $container ): array {
|
||||
|
|
|
@ -9,6 +9,7 @@ declare( strict_types=1 );
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\Webhooks\Status\WebhooksStatusPage;
|
||||
|
||||
|
@ -33,15 +34,24 @@ class SectionsRenderer {
|
|||
*/
|
||||
protected $sections;
|
||||
|
||||
/**
|
||||
* The onboarding state.
|
||||
*
|
||||
* @var State
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* SectionsRenderer constructor.
|
||||
*
|
||||
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
||||
* @param array<string, string> $sections Key - page/gateway ID, value - displayed text.
|
||||
* @param State $state The onboarding state.
|
||||
*/
|
||||
public function __construct( string $page_id, array $sections ) {
|
||||
public function __construct( string $page_id, array $sections, State $state ) {
|
||||
$this->page_id = $page_id;
|
||||
$this->sections = $sections;
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +60,9 @@ class SectionsRenderer {
|
|||
* @return bool
|
||||
*/
|
||||
public function should_render() : bool {
|
||||
return ! empty( $this->page_id );
|
||||
return ! empty( $this->page_id ) &&
|
||||
( $this->state->production_state() === State::STATE_ONBOARDED ||
|
||||
$this->state->sandbox_state() === State::STATE_ONBOARDED );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue