mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge branch 'PCP-32-layout-options-per-context'
This commit is contained in:
commit
0e9f329c5e
6 changed files with 545 additions and 105 deletions
|
@ -15,7 +15,7 @@ class Renderer {
|
|||
return;
|
||||
}
|
||||
|
||||
const style = this.defaultConfig.button.style;
|
||||
const style = wrapper === this.defaultConfig.button.wrapper ? this.defaultConfig.button.style : this.defaultConfig.button.mini_cart_style;
|
||||
paypal.Buttons({
|
||||
style,
|
||||
...contextConfig,
|
||||
|
|
|
@ -136,8 +136,8 @@ class SmartButton implements SmartButtonInterface
|
|||
31
|
||||
);
|
||||
}
|
||||
$notEnabledOnMiniCart = $this->settings->has('button_mini_cart_enabled') &&
|
||||
!$this->settings->get('button_mini_cart_enabled');
|
||||
$notEnabledOnMiniCart = $this->settings->has('button_mini-cart_enabled') &&
|
||||
!$this->settings->get('button_mini-cart_enabled');
|
||||
if (
|
||||
! $notEnabledOnMiniCart
|
||||
) {
|
||||
|
@ -336,14 +336,19 @@ class SmartButton implements SmartButtonInterface
|
|||
'mini_cart_wrapper' => '#ppc-button-minicart',
|
||||
'cancel_wrapper' => '#ppcp-cancel',
|
||||
'url' => $this->url(),
|
||||
'mini_cart_style' => [
|
||||
'layout' => $this->styleForContext('layout', 'mini-cart'),
|
||||
'size' => $this->styleForContext('size', 'mini-cart'),
|
||||
'color' => $this->styleForContext('color', 'mini-cart'),
|
||||
'shape' => $this->styleForContext('shape', 'mini-cart'),
|
||||
'label' => $this->styleForContext('label', 'mini-cart'),
|
||||
],
|
||||
'style' => [
|
||||
'layout' => 'vertical',
|
||||
'color' => ($this->settings->has('button_color')) ?
|
||||
$this->settings->get('button_color') : null,
|
||||
'shape' => ($this->settings->has('button_shape')) ?
|
||||
$this->settings->get('button_shape') : null,
|
||||
'label' => ($this->settings->has('button_label')) ?
|
||||
$this->settings->get('button_label') : 'paypal',
|
||||
'layout' => $this->styleForContext('layout', $this->context()),
|
||||
'size' => $this->styleForContext('size', $this->context()),
|
||||
'color' => $this->styleForContext('color', $this->context()),
|
||||
'shape' => $this->styleForContext('shape', $this->context()),
|
||||
'label' => $this->styleForContext('label', $this->context()),
|
||||
],
|
||||
],
|
||||
'hosted_fields' => [
|
||||
|
@ -489,4 +494,23 @@ class SmartButton implements SmartButtonInterface
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function styleForContext(string $style, string $context): string
|
||||
{
|
||||
$defaults = [
|
||||
'layout' => 'vertical',
|
||||
'size' => 'responsive',
|
||||
'color' => 'gold',
|
||||
'shape' => 'pill',
|
||||
'label' => 'paypal',
|
||||
];
|
||||
|
||||
$value = isset($defaults[$style]) ?
|
||||
$defaults[$style] : '';
|
||||
$value = $this->settings->has('button_' . $style) ?
|
||||
$this->settings->get('button_' . $style) : $value;
|
||||
$value = $this->settings->has('button_' . $context . '_' . $style) ?
|
||||
$this->settings->get('button_' . $context . '_' . $style) : $value;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,61 +270,6 @@ return [
|
|||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_single_product_enabled' => [
|
||||
'title' => __('Buttons on Single Product', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Single Product', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini_cart_enabled' => [
|
||||
'title' => __('Buttons on Mini Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Mini Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_enabled' => [
|
||||
'title' => __('Buttons on Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_label' => [
|
||||
'title' => __('Button Label', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'paypal',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the label on the primary button.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'paypal' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
'checkout' => __('PayPal Checkout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'buynow' => __('PayPal Buy Now', 'woocommerce-paypal-commerce-gateway'),
|
||||
'pay' => __('Pay with PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'brand_name' => [
|
||||
'title' => __('Brand Name', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'text',
|
||||
|
@ -360,6 +305,121 @@ return [
|
|||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'disable_funding' => [
|
||||
'title' => __('Disable funding sources', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'ppcp-multiselect',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => [],
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'By default all possible funding sources will be shown. You can disable some sources, if you wish.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'card' => _x('Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'credit' => _x('PayPal Credit', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'sepa' => _x('SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'bancontact' => _x('Bancontact', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'eps' => _x('eps', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'giropay' => _x('giropay', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'ideal' => _x('iDEAL', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'mybank' => _x('MyBank', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'p24' => _x('Przelewy24', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'sofort' => _x('Sofort', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'vault_enabled' => [
|
||||
'title' => __('Vaulting', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
'label' => __('Enable vaulting', 'woocommerce-paypal-commerce-gateway'),
|
||||
'description' => __('Enables you to store payment tokens for subscriptions.', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
|
||||
//General button styles
|
||||
'button_style_heading' => [
|
||||
'heading' => __('General styles', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_layout' => [
|
||||
'title' => __('Button Layout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'vertical',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'vertical' => __('Vertical', 'woocommerce-paypal-commerce-gateway'),
|
||||
'horizontal' => __('Horizontal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_size' => [
|
||||
'title' => __('Button Size', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'responsive',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'PayPal offers different sizes of the "PayPal Checkout" buttons, allowing you to select a size that best fits your site\'s theme. This setting will allow you to choose which size button(s) appear on your page. (The "Responsive" option adjusts to container size, and is available and recommended for Smart Payment Buttons.)',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'small' => __('Small', 'woocommerce-paypal-commerce-gateway'),
|
||||
'medium' => __('Medium', 'woocommerce-paypal-commerce-gateway'),
|
||||
'large' => __('Large', 'woocommerce-paypal-commerce-gateway'),
|
||||
'responsive' => __('Responsive', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_label' => [
|
||||
'title' => __('Button Label', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'paypal',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the label on the primary button.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'paypal' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
'checkout' => __('PayPal Checkout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'buynow' => __('PayPal Buy Now', 'woocommerce-paypal-commerce-gateway'),
|
||||
'pay' => __('Pay with PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_color' => [
|
||||
'title' => __('Color', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
|
@ -402,27 +462,41 @@ return [
|
|||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'disable_funding' => [
|
||||
'title' => __('Disable funding sources', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'ppcp-multiselect',
|
||||
|
||||
//Single product page
|
||||
'button_single_product_heading' => [
|
||||
'heading' => __('Single Product page', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_single_product_enabled' => [
|
||||
'title' => __('Enable buttons on Single Product', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Single Product', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_single_product_layout' => [
|
||||
'title' => __('Button Layout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => [],
|
||||
'default' => 'vertical',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'By default all possible funding sources will be shown. You can disable some sources, if you wish.',
|
||||
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'card' => _x('Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'credit' => _x('PayPal Credit', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'sepa' => _x('SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'bancontact' => _x('Bancontact', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'eps' => _x('eps', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'giropay' => _x('giropay', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'ideal' => _x('iDEAL', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'mybank' => _x('MyBank', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'p24' => _x('Przelewy24', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'sofort' => _x('Sofort', 'Name of payment method', 'woocommerce-paypal-commerce-gateway'),
|
||||
'vertical' => __('Vertical', 'woocommerce-paypal-commerce-gateway'),
|
||||
'horizontal' => __('Horizontal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
|
@ -430,18 +504,349 @@ return [
|
|||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'vault_enabled' => [
|
||||
'title' => __('Vaulting', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'button_single_product_size' => [
|
||||
'title' => __('Button Size', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'responsive',
|
||||
'desc_tip' => true,
|
||||
'label' => __('Enable vaulting', 'woocommerce-paypal-commerce-gateway'),
|
||||
'description' => __('Enables you to store payment tokens for subscriptions.', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'description' => __(
|
||||
'PayPal offers different sizes of the "PayPal Checkout" buttons, allowing you to select a size that best fits your site\'s theme. This setting will allow you to choose which size button(s) appear on your page. (The "Responsive" option adjusts to container size, and is available and recommended for Smart Payment Buttons.)',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'small' => __('Small', 'woocommerce-paypal-commerce-gateway'),
|
||||
'medium' => __('Medium', 'woocommerce-paypal-commerce-gateway'),
|
||||
'large' => __('Large', 'woocommerce-paypal-commerce-gateway'),
|
||||
'responsive' => __('Responsive', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_single_product_label' => [
|
||||
'title' => __('Button Label', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'paypal',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the label on the primary button.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'paypal' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
'checkout' => __('PayPal Checkout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'buynow' => __('PayPal Buy Now', 'woocommerce-paypal-commerce-gateway'),
|
||||
'pay' => __('Pay with PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_single_product_color' => [
|
||||
'title' => __('Color', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'gold',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'gold' => __('Gold (Recommended)', 'woocommerce-paypal-commerce-gateway'),
|
||||
'blue' => __('Blue', 'woocommerce-paypal-commerce-gateway'),
|
||||
'silver' => __('Silver', 'woocommerce-paypal-commerce-gateway'),
|
||||
'black' => __('Black', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_single_product_shape' => [
|
||||
'title' => __('Shape', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'rect',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'pill' => __('Pill', 'woocommerce-paypal-commerce-gateway'),
|
||||
'rect' => __('Rectangle', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
|
||||
//Mini cart settings
|
||||
'button_mini-cart_heading' => [
|
||||
'heading' => __('Mini Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini-cart_enabled' => [
|
||||
'title' => __('Buttons on Mini Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Mini Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini-cart_layout' => [
|
||||
'title' => __('Button Layout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'vertical',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'vertical' => __('Vertical', 'woocommerce-paypal-commerce-gateway'),
|
||||
'horizontal' => __('Horizontal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini-cart_size' => [
|
||||
'title' => __('Button Size', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'responsive',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'PayPal offers different sizes of the "PayPal Checkout" buttons, allowing you to select a size that best fits your site\'s theme. This setting will allow you to choose which size button(s) appear on your page. (The "Responsive" option adjusts to container size, and is available and recommended for Smart Payment Buttons.)',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'small' => __('Small', 'woocommerce-paypal-commerce-gateway'),
|
||||
'medium' => __('Medium', 'woocommerce-paypal-commerce-gateway'),
|
||||
'large' => __('Large', 'woocommerce-paypal-commerce-gateway'),
|
||||
'responsive' => __('Responsive', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini-cart_label' => [
|
||||
'title' => __('Button Label', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'paypal',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the label on the primary button.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'paypal' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
'checkout' => __('PayPal Checkout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'buynow' => __('PayPal Buy Now', 'woocommerce-paypal-commerce-gateway'),
|
||||
'pay' => __('Pay with PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini-cart_color' => [
|
||||
'title' => __('Color', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'gold',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'gold' => __('Gold (Recommended)', 'woocommerce-paypal-commerce-gateway'),
|
||||
'blue' => __('Blue', 'woocommerce-paypal-commerce-gateway'),
|
||||
'silver' => __('Silver', 'woocommerce-paypal-commerce-gateway'),
|
||||
'black' => __('Black', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_mini-cart_shape' => [
|
||||
'title' => __('Shape', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'rect',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'pill' => __('Pill', 'woocommerce-paypal-commerce-gateway'),
|
||||
'rect' => __('Rectangle', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
|
||||
//Cart settings
|
||||
'button_cart_heading' => [
|
||||
'heading' => __('Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_enabled' => [
|
||||
'title' => __('Buttons on Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => true,
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_layout' => [
|
||||
'title' => __('Button Layout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'vertical',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'vertical' => __('Vertical', 'woocommerce-paypal-commerce-gateway'),
|
||||
'horizontal' => __('Horizontal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_size' => [
|
||||
'title' => __('Button Size', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'responsive',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'PayPal offers different sizes of the "PayPal Checkout" buttons, allowing you to select a size that best fits your site\'s theme. This setting will allow you to choose which size button(s) appear on your page. (The "Responsive" option adjusts to container size, and is available and recommended for Smart Payment Buttons.)',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'small' => __('Small', 'woocommerce-paypal-commerce-gateway'),
|
||||
'medium' => __('Medium', 'woocommerce-paypal-commerce-gateway'),
|
||||
'large' => __('Large', 'woocommerce-paypal-commerce-gateway'),
|
||||
'responsive' => __('Responsive', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_label' => [
|
||||
'title' => __('Button Label', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'paypal',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the label on the primary button.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'paypal' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
'checkout' => __('PayPal Checkout', 'woocommerce-paypal-commerce-gateway'),
|
||||
'buynow' => __('PayPal Buy Now', 'woocommerce-paypal-commerce-gateway'),
|
||||
'pay' => __('Pay with PayPal', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_color' => [
|
||||
'title' => __('Color', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'gold',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'gold' => __('Gold (Recommended)', 'woocommerce-paypal-commerce-gateway'),
|
||||
'blue' => __('Blue', 'woocommerce-paypal-commerce-gateway'),
|
||||
'silver' => __('Silver', 'woocommerce-paypal-commerce-gateway'),
|
||||
'black' => __('Black', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'button_cart_shape' => [
|
||||
'title' => __('Shape', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => ['wc-enhanced-select'],
|
||||
'default' => 'rect',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'pill' => __('Pill', 'woocommerce-paypal-commerce-gateway'),
|
||||
'rect' => __('Rectangle', 'woocommerce-paypal-commerce-gateway'),
|
||||
],
|
||||
'screens' => [
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
|
||||
'dcc_cart_enabled' => [
|
||||
'title' => __('Enable credit card on cart', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'checkbox',
|
||||
|
|
|
@ -77,7 +77,7 @@ class Settings implements ContainerInterface
|
|||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
'button_single_product_enabled' => true,
|
||||
'button_mini_cart_enabled' => true,
|
||||
'button_mini-cart_enabled' => true,
|
||||
'button_cart_enabled' => true,
|
||||
'dcc_cart_enabled' => true,
|
||||
'dcc_mini_cart_enabled' => true,
|
||||
|
|
|
@ -104,8 +104,25 @@ class SettingsRenderer
|
|||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function renderHeading($field, $key, $config, $value): string
|
||||
{
|
||||
|
||||
if ($config['type'] !== 'ppcp-heading') {
|
||||
return $field;
|
||||
}
|
||||
|
||||
$html = sprintf(
|
||||
'<h3 class="%s">%s</h3>',
|
||||
esc_attr(implode(' ', $config['class'])),
|
||||
esc_html($config['heading'])
|
||||
);
|
||||
|
||||
return $html;
|
||||
}
|
||||
//phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration.NoArgumentType
|
||||
|
||||
//phpcs:disable Inpsyde.CodeQuality.NestingLevel.High
|
||||
public function render()
|
||||
{
|
||||
|
||||
|
@ -122,9 +139,12 @@ class SettingsRenderer
|
|||
}
|
||||
$value = $this->settings->has($field) ? $this->settings->get($field) : null;
|
||||
$id = 'ppcp[' . $field . ']';
|
||||
$thTd = $config['type'] !== 'ppcp-heading' ? 'td' : 'th';
|
||||
$colspan = $config['type'] !== 'ppcp-heading' ? 1 : 2;
|
||||
|
||||
?>
|
||||
<tr valign="top" id="<?php echo esc_attr('field-' . $field); ?>">
|
||||
<?php if ($config['type'] !== 'ppcp-heading') : ?>
|
||||
<th>
|
||||
<label
|
||||
for="<?php echo esc_attr($id); ?>"
|
||||
|
@ -137,13 +157,15 @@ class SettingsRenderer
|
|||
<?php unset($config['description']);
|
||||
endif; ?>
|
||||
</th>
|
||||
<td><?php
|
||||
<?php endif; ?>
|
||||
<<?php echo $thTd; ?> colspan="<?php echo (int) $colspan; ?>"><?php
|
||||
$config['type'] === 'ppcp-text' ?
|
||||
$this->renderText($config)
|
||||
: woocommerce_form_field($id, $config, $value); ?></td>
|
||||
: woocommerce_form_field($id, $config, $value); ?></<?php echo $thTd; ?>>
|
||||
</tr>
|
||||
<?php endforeach;
|
||||
}
|
||||
//phpcs:enable Inpsyde.CodeQuality.NestingLevel.High
|
||||
|
||||
private function renderText(array $config)
|
||||
{
|
||||
|
|
|
@ -118,22 +118,11 @@ class WcGatewayModule implements ModuleInterface
|
|||
/**
|
||||
* @var SettingsRenderer $renderer
|
||||
*/
|
||||
return $renderer->renderPassword(
|
||||
$renderer->renderTextInput(
|
||||
$renderer->renderMultiSelect(
|
||||
$field,
|
||||
$key,
|
||||
$args,
|
||||
$value
|
||||
),
|
||||
$key,
|
||||
$args,
|
||||
$value
|
||||
),
|
||||
$key,
|
||||
$args,
|
||||
$value
|
||||
);
|
||||
$field = $renderer->renderMultiSelect($field, $key, $args, $value);
|
||||
$field = $renderer->renderPassword($field, $key, $args, $value);
|
||||
$field = $renderer->renderTextInput($field, $key, $args, $value);
|
||||
$field = $renderer->renderHeading($field, $key, $args, $value);
|
||||
return $field;
|
||||
},
|
||||
10,
|
||||
4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue