diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 4bacab63a..e0001821c 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -1790,15 +1790,18 @@ return array( $section_id = PayPalGateway::ID; $pay_later_tab_id = Settings::PAY_LATER_TAB_ID; - return array( - array( + $list_of_config = array(); + + if ( $container->get('paylater-configurator.is-available') ) { + $list_of_config[] = array( 'id' => 'pay-later-messaging-task', 'title' => __( 'Configure PayPal Pay Later messaging', 'woocommerce-paypal-payments' ), 'description' => __( 'Decide where you want dynamic Pay Later messaging to show up and how you want it to look on your site.', 'woocommerce-paypal-payments' ), 'redirect_url' => admin_url("admin.php?page=wc-settings&tab=checkout§ion={$section_id}&ppcp-tab={$pay_later_tab_id}"), - 'is_enabled' => $container->get('paylater-configurator.is-available'), - ), - ); + ); + } + + return $list_of_config; }, /** @@ -1818,8 +1821,7 @@ return array( $title = $config['title'] ?? ''; $description = $config['description'] ?? ''; $redirect_url = $config['redirect_url'] ?? ''; - $is_enabled = $config['is_enabled'] ?? false; - $simple_redirect_tasks[] = $simple_redirect_task_factory->create_task( $id, $title, $description, $redirect_url, $is_enabled ); + $simple_redirect_tasks[] = $simple_redirect_task_factory->create_task( $id, $title, $description, $redirect_url ); } return $simple_redirect_tasks; diff --git a/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactory.php b/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactory.php index be21d6cfa..7f9d6e893 100644 --- a/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactory.php +++ b/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactory.php @@ -17,7 +17,7 @@ class SimpleRedirectTaskFactory implements SimpleRedirectTaskFactoryInterface { /** * {@inheritDoc} */ - public function create_task( string $id, string $title, string $description, string $redirect_url, bool $is_enabled ): SimpleRedirectTask { - return new SimpleRedirectTask( $id, $title, $description, $redirect_url, $is_enabled ); + public function create_task( string $id, string $title, string $description, string $redirect_url ): SimpleRedirectTask { + return new SimpleRedirectTask( $id, $title, $description, $redirect_url ); } } diff --git a/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactoryInterface.php b/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactoryInterface.php index f8d17b57f..8931622d4 100644 --- a/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactoryInterface.php +++ b/modules/ppcp-wc-gateway/src/Settings/WcTasks/Factory/SimpleRedirectTaskFactoryInterface.php @@ -20,8 +20,7 @@ interface SimpleRedirectTaskFactoryInterface { * @param string $title The task title. * @param string $description The task description. * @param string $redirect_url The redirection URL. - * @param bool $is_enabled Whether the task is enabled. * @return SimpleRedirectTask The task. */ - public function create_task( string $id, string $title, string $description, string $redirect_url, bool $is_enabled ): SimpleRedirectTask; + public function create_task( string $id, string $title, string $description, string $redirect_url ): SimpleRedirectTask; } diff --git a/modules/ppcp-wc-gateway/src/Settings/WcTasks/Tasks/SimpleRedirectTask.php b/modules/ppcp-wc-gateway/src/Settings/WcTasks/Tasks/SimpleRedirectTask.php index 104a9be6d..b187f6b17 100644 --- a/modules/ppcp-wc-gateway/src/Settings/WcTasks/Tasks/SimpleRedirectTask.php +++ b/modules/ppcp-wc-gateway/src/Settings/WcTasks/Tasks/SimpleRedirectTask.php @@ -44,14 +44,6 @@ class SimpleRedirectTask extends Task { */ protected string $redirect_url; - /** - * Whether the task is enabled. - * - * @var bool - */ - protected bool $is_enabled; - - /** * SimpleRedirectTask constructor. * @@ -59,16 +51,14 @@ class SimpleRedirectTask extends Task { * @param string $title The task title. * @param string $description The task description. * @param string $redirect_url The redirection URL. - * @param bool $is_enabled Whether the task is enabled. */ - public function __construct( string $id, string $title, string $description, string $redirect_url, bool $is_enabled ) { + public function __construct( string $id, string $title, string $description, string $redirect_url ) { parent::__construct(); $this->id = $id; $this->title = $title; $this->description = $description; $this->redirect_url = $redirect_url; - $this->is_enabled = $is_enabled; } /** @@ -116,15 +106,6 @@ class SimpleRedirectTask extends Task { return $this->redirect_url; } - /** - * Whether the task is enabled. - * - * @return bool - */ - public function is_enabled(): bool { - return $this->is_enabled; - } - /** * The task completion. * diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index eab936f52..5a7ca2c62 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -843,7 +843,11 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul */ protected function register_wc_tasks( ContainerInterface $container ): void { $simple_redirect_tasks = $container->get( 'wcgateway.settings.wc-tasks.simple-redirect-tasks' ); - $task_registrar = $container->get( 'wcgateway.settings.wc-tasks.task-registrar' ); + if ( empty( $simple_redirect_tasks ) ) { + return; + } + + $task_registrar = $container->get( 'wcgateway.settings.wc-tasks.task-registrar' ); assert( $task_registrar instanceof TaskRegistrarInterface ); $logger = $container->get( 'woocommerce.logger.woocommerce' );