mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
prepare code to work with connection tab
This commit is contained in:
parent
2cbdfdf3bb
commit
4a8c8eeb8e
4 changed files with 26 additions and 6 deletions
|
@ -26,6 +26,7 @@ use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\Webhooks\Status\WebhooksStatusPage;
|
||||
|
@ -290,6 +291,9 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
* @return string
|
||||
*/
|
||||
private function define_method_title(): string {
|
||||
if ( $this->is_connection_tab() ) {
|
||||
return __( 'Account Setup', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
if ( $this->is_credit_card_tab() ) {
|
||||
return __( 'PayPal Card Processing', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
@ -312,6 +316,10 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
* @return string
|
||||
*/
|
||||
private function define_method_description(): string {
|
||||
if ( $this->is_connection_tab() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $this->is_credit_card_tab() ) {
|
||||
return __(
|
||||
'Accept debit and credit cards, and local payment methods.',
|
||||
|
@ -374,6 +382,16 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
&& WebhooksStatusPage::ID === $this->page_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we are on the connection tab.
|
||||
*
|
||||
* @return bool true if is connection tab, otherwise false
|
||||
*/
|
||||
protected function is_connection_tab() : bool {
|
||||
return is_admin()
|
||||
&& Settings::CONNECTION_TAB_ID === $this->page_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we are on the PayPal settings tab.
|
||||
*
|
||||
|
|
|
@ -33,10 +33,11 @@ trait PageMatcherTrait {
|
|||
}
|
||||
|
||||
$gateway_page_id_map = array(
|
||||
PayPalGateway::ID => 'paypal',
|
||||
CreditCardGateway::ID => 'dcc', // TODO: consider using just the gateway ID for PayPal and DCC too.
|
||||
CardButtonGateway::ID => CardButtonGateway::ID,
|
||||
WebhooksStatusPage::ID => WebhooksStatusPage::ID,
|
||||
Settings::CONNECTION_TAB_ID => 'connection',
|
||||
PayPalGateway::ID => 'paypal',
|
||||
CreditCardGateway::ID => 'dcc', // TODO: consider using just the gateway ID for PayPal and DCC too.
|
||||
CardButtonGateway::ID => CardButtonGateway::ID,
|
||||
WebhooksStatusPage::ID => WebhooksStatusPage::ID,
|
||||
);
|
||||
return array_key_exists( $current_page_id, $gateway_page_id_map )
|
||||
&& in_array( $gateway_page_id_map[ $current_page_id ], $allowed_gateways, true );
|
||||
|
|
|
@ -77,7 +77,7 @@ class SectionsRenderer {
|
|||
|
||||
foreach ( $this->sections as $id => $label ) {
|
||||
$url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $id );
|
||||
if ( in_array( $id, array( CreditCardGateway::ID, WebhooksStatusPage::ID ), true ) ) {
|
||||
if ( in_array( $id, array( Settings::CONNECTION_TAB_ID, CreditCardGateway::ID, WebhooksStatusPage::ID ), true ) ) {
|
||||
// We need section=ppcp-gateway for the webhooks page because it is not a gateway,
|
||||
// and for DCC because otherwise it will not render the page if gateway is not available (country/currency).
|
||||
// Other gateways render fields differently, and their pages are not expected to work when gateway is not available.
|
||||
|
|
|
@ -17,7 +17,8 @@ use Psr\Container\ContainerInterface;
|
|||
*/
|
||||
class Settings implements ContainerInterface {
|
||||
|
||||
const KEY = 'woocommerce-ppcp-settings';
|
||||
const KEY = 'woocommerce-ppcp-settings';
|
||||
const CONNECTION_TAB_ID = 'ppcp-connection';
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue