diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index f8c8e5abe..2ead04fc2 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -23,6 +23,7 @@ use Inpsyde\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice; use Inpsyde\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice; use Inpsyde\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor; use Inpsyde\PayPalCommerce\WcGateway\Processor\OrderProcessor; +use Inpsyde\PayPalCommerce\WcGateway\Settings\SectionsRenderer; use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings; use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsListener; use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsRenderer; @@ -81,6 +82,9 @@ return array( static function ( ContainerInterface $container ): AuthorizeOrderActionNotice { return new AuthorizeOrderActionNotice(); }, + 'wcgateway.settings.sections-renderer' => static function ( ContainerInterface $container ): SectionsRenderer { + return new SectionsRenderer(); + }, 'wcgateway.settings.render' => static function ( ContainerInterface $container ): SettingsRenderer { $settings = $container->get( 'wcgateway.settings' ); $state = $container->get( 'onboarding.state' ); diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php index 90aa5205f..9d8e735f6 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php @@ -123,20 +123,6 @@ class CreditCardGateway extends PayPalGateway { ); } - /** - * Renders the settings. - * - * @return string - */ - public function generate_ppcp_html(): string { - - ob_start(); - $this->settings_renderer->render( true ); - $content = ob_get_contents(); - ob_end_clean(); - return $content; - } - /** * Returns the title of the gateway. * diff --git a/modules/ppcp-wc-gateway/src/Settings/class-sectionrenderer.php b/modules/ppcp-wc-gateway/src/Settings/class-sectionrenderer.php new file mode 100644 index 000000000..489622e72 --- /dev/null +++ b/modules/ppcp-wc-gateway/src/Settings/class-sectionrenderer.php @@ -0,0 +1,41 @@ +should_render()) { + return; + } + + $current = ! isset($_GET[self::KEY]) ? 'paypal' : sanitize_text_field(wp_unslash($_GET[self::KEY])); + $sections = [ + 'paypal' => __( 'PayPal', 'paypal-for-woocommerce' ), + 'dcc' => __( 'Credit Card', 'paypal-for-woocommerce' ), + ]; + + echo '
'; + return; + } +} \ No newline at end of file diff --git a/modules/ppcp-wc-gateway/src/Settings/class-settingsrenderer.php b/modules/ppcp-wc-gateway/src/Settings/class-settingsrenderer.php index 510f448d9..53625e725 100644 --- a/modules/ppcp-wc-gateway/src/Settings/class-settingsrenderer.php +++ b/modules/ppcp-wc-gateway/src/Settings/class-settingsrenderer.php @@ -209,11 +209,10 @@ class SettingsRenderer { /** * Renders the settings. - * - * @param bool $is_dcc Whether it is the DCC gateway or not. */ - public function render( bool $is_dcc ) { + public function render() { + $is_dcc = isset($_GET[SectionsRenderer::KEY]) && 'dcc' === sanitize_text_field(wp_unslash($_GET[SectionsRenderer::KEY])); $nonce = wp_create_nonce( SettingsListener::NONCE ); ?> diff --git a/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php b/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php index e05ed60c5..1a55da933 100644 --- a/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php +++ b/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php @@ -22,6 +22,7 @@ use Inpsyde\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint; use Inpsyde\PayPalCommerce\WcGateway\Gateway\CreditCardGateway; use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use Inpsyde\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice; +use Inpsyde\PayPalCommerce\WcGateway\Settings\SectionsRenderer; use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings; use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsRenderer; use Interop\Container\ServiceProviderInterface; @@ -56,6 +57,19 @@ class WcGatewayModule implements ModuleInterface { $this->register_checkout_paypal_address_preset( $container ); $this->ajax_gateway_enabler( $container ); + add_action( + 'woocommerce_sections_checkout', + function() use ($container) { + $section_renderer = $container->get('wcgateway.settings.sections-renderer'); + /** + * The Section Renderer. + * + * @var SectionsRenderer $section_renderer + */ + $section_renderer->render(); + } + ); + add_filter( Repository::NOTICES_FILTER, static function ( $notices ) use ( $container ): array {