mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Merge pull request #3527 from woocommerce/PCP-4999-pay-pal-configuration-description-logo-not-working-as-expected
Fix empty description handling and logo display for PayPal gateway (4999)
This commit is contained in:
commit
206804cab0
4 changed files with 29 additions and 3 deletions
|
@ -260,7 +260,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
'src' => $this->gateway->icon,
|
||||
),
|
||||
),
|
||||
'description' => $this->gateway->description,
|
||||
'description' => $this->gateway->get_description(),
|
||||
'smartButtonsEnabled' => $smart_buttons_enabled,
|
||||
'placeOrderEnabled' => $place_order_enabled,
|
||||
'fundingSource' => $this->session_handler->funding_source(),
|
||||
|
|
|
@ -136,7 +136,7 @@ class PaymentMethodsDefinition {
|
|||
$gateway = $this->wc_gateways[ $gateway_id ] ?? null;
|
||||
|
||||
$gateway_title = $gateway ? $gateway->get_title() : $title;
|
||||
$gateway_description = $gateway ? $gateway->get_description() : $description;
|
||||
$gateway_description = $gateway->settings['description'] ?? $description;
|
||||
$enabled = $this->settings->is_method_enabled( $gateway_id );
|
||||
$config = array(
|
||||
'id' => $gateway_id,
|
||||
|
@ -159,7 +159,7 @@ class PaymentMethodsDefinition {
|
|||
),
|
||||
'checkoutPageDescription' => array(
|
||||
'type' => 'text',
|
||||
'default' => $gateway ? $gateway->get_description() : '',
|
||||
'default' => $gateway_description,
|
||||
'label' => __( 'Checkout page description', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -531,6 +531,17 @@ class SettingsModule implements ServiceModule, ExecutableModule {
|
|||
2
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_paypal_gateway_icon',
|
||||
function ( string $icon_url ) use ( $container ) {
|
||||
$payment_settings = $container->get( 'settings.data.payment' );
|
||||
assert( $payment_settings instanceof PaymentSettings );
|
||||
|
||||
// If "Show logo" is disabled, return an empty string to hide the icon.
|
||||
return $payment_settings->get_paypal_show_logo() ? $icon_url : '';
|
||||
}
|
||||
);
|
||||
|
||||
add_filter( 'woocommerce_paypal_payments_card_button_gateway_should_register_gateway', '__return_true' );
|
||||
|
||||
add_filter(
|
||||
|
|
|
@ -351,6 +351,21 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
return parent::get_title();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the gateway's description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
$gateway_settings = get_option( $this->get_option_key(), array() );
|
||||
|
||||
if ( array_key_exists( 'description', $gateway_settings ) ) {
|
||||
return $gateway_settings['description'];
|
||||
}
|
||||
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the Gateway needs to be setup.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue