Merge pull request #1770 from woocommerce/PCP-798-paylater-locations

Improve Pay Later messages and add Shop, Home locations
This commit is contained in:
Emili Castells 2023-10-17 12:03:42 +02:00 committed by GitHub
commit 814c9fcd36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 474 additions and 75 deletions

View file

@ -7,3 +7,7 @@
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
}
.ppc-button-wrapper #ppcp-messages:first-child {
padding-top: 10px;
}

View file

@ -156,8 +156,15 @@ class CheckoutBootstap {
}
shouldShowMessages() {
return getCurrentPaymentMethod() === PaymentMethods.PAYPAL
&& !PayPalCommerceGateway.is_free_trial_cart;
// hide when another method selected only if messages are near buttons
const messagesWrapper = document.querySelector(this.gateway.messages.wrapper);
if (getCurrentPaymentMethod() !== PaymentMethods.PAYPAL &&
messagesWrapper && jQuery(messagesWrapper).closest('.ppc-button-wrapper').length
) {
return false;
}
return !PayPalCommerceGateway.is_free_trial_cart;
}
disableCreditCardFields() {

View file

@ -28,15 +28,9 @@ class MessageRenderer {
return;
}
const newWrapper = document.createElement('div');
newWrapper.setAttribute('id', this.config.wrapper.replace('#', ''));
const wrapper = document.querySelector(this.config.wrapper);
this.currentNumber++;
newWrapper.setAttribute('data-render-number', this.currentNumber);
const oldWrapper = document.querySelector(this.config.wrapper);
const sibling = oldWrapper.nextSibling;
oldWrapper.parentElement.removeChild(oldWrapper);
sibling.parentElement.insertBefore(newWrapper, sibling);
wrapper.setAttribute('data-render-number', this.currentNumber);
widgetBuilder.registerMessages(this.config.wrapper, options);
widgetBuilder.renderMessages(this.config.wrapper);

View file

@ -84,11 +84,14 @@ class WidgetBuilder {
return;
}
const entry = this.messages.get(wrapper);
if (this.hasRendered(wrapper)) {
const element = document.querySelector(wrapper);
element.setAttribute('data-pp-amount', entry.options.amount);
return;
}
const entry = this.messages.get(wrapper);
const btn = this.paypal.Messages(entry.options);
btn.render(entry.wrapper);

View file

@ -382,54 +382,48 @@ class SmartButton implements SmartButtonInterface {
* Registers the hooks to render the credit messaging HTML depending on the settings.
*
* @return bool
* @throws NotFoundException When a setting was not found.
*/
private function render_message_wrapper_registrar(): bool {
if ( ! $this->settings_status->is_pay_later_messaging_enabled() ) {
return false;
}
$selected_locations = $this->settings->has( 'pay_later_messaging_locations' ) ? $this->settings->get( 'pay_later_messaging_locations' ) : array();
$location = $this->location();
$not_enabled_on_cart = ! in_array( 'cart', $selected_locations, true );
if ( ! $this->settings_status->is_pay_later_messaging_enabled_for_location( $location ) ) {
return false;
}
$get_hook = function ( string $location ): ?array {
switch ( $location ) {
case 'checkout':
return $this->messages_renderer_hook( $location, 'woocommerce_review_order_before_payment', 10 );
case 'cart':
return $this->messages_renderer_hook( $location, $this->proceed_to_checkout_button_renderer_hook(), 19 );
case 'pay-now':
return $this->messages_renderer_hook( 'pay_order', 'woocommerce_pay_order_before_submit', 10 );
case 'product':
return $this->messages_renderer_hook( $location, $this->single_product_renderer_hook(), 30 );
case 'shop':
return $this->messages_renderer_hook( $location, 'woocommerce_archive_description', 10 );
case 'home':
return $this->messages_renderer_hook( $location, 'loop_start', 20 );
default:
return null;
}
};
$hook = $get_hook( $location );
if ( ! $hook ) {
return false;
}
add_action(
$this->proceed_to_checkout_button_renderer_hook(),
function() use ( $not_enabled_on_cart ) {
if ( ! is_cart() || $not_enabled_on_cart ) {
return;
}
$this->message_renderer();
},
19
$hook['name'],
array( $this, 'message_renderer' ),
$hook['priority']
);
$not_enabled_on_product_page = ! in_array( 'product', $selected_locations, true );
if (
( is_product() || wc_post_content_has_shortcode( 'product_page' ) )
&& ! $not_enabled_on_product_page
&& ! is_checkout()
) {
add_action(
$this->single_product_renderer_hook(),
array( $this, 'message_renderer' ),
30
);
}
$not_enabled_on_checkout = ! in_array( 'checkout', $selected_locations, true );
if ( ! $not_enabled_on_checkout ) {
add_action(
$this->checkout_dcc_button_renderer_hook(),
array( $this, 'message_renderer' ),
11
);
add_action(
$this->pay_order_renderer_hook(),
array( $this, 'message_renderer' ),
15
);
}
return true;
}
@ -528,8 +522,8 @@ class SmartButton implements SmartButtonInterface {
* Whether any of our scripts (for DCC or product, mini-cart, non-block cart/checkout) should be loaded.
*/
public function should_load_ppcp_script(): bool {
$buttons_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
if ( ! $buttons_enabled ) {
$pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
if ( ! $pcp_gateway_enabled ) {
return false;
}
@ -537,37 +531,65 @@ class SmartButton implements SmartButtonInterface {
return false;
}
return $this->should_load_buttons() || $this->can_render_dcc();
return $this->should_load_buttons() || $this->should_load_messages() || $this->can_render_dcc();
}
/**
* Determines whether the button component should be loaded.
*/
public function should_load_buttons() : bool {
$buttons_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
if ( ! $buttons_enabled ) {
$pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
if ( ! $pcp_gateway_enabled ) {
return false;
}
$smart_button_enabled_for_current_location = $this->settings_status->is_smart_button_enabled_for_location( $this->context() );
$smart_button_enabled_for_mini_cart = $this->settings_status->is_smart_button_enabled_for_location( 'mini-cart' );
$messaging_enabled_for_current_location = $this->settings_status->is_pay_later_messaging_enabled_for_location( $this->context() );
switch ( $this->context() ) {
case 'checkout':
case 'cart':
case 'pay-now':
return $smart_button_enabled_for_current_location || $messaging_enabled_for_current_location;
case 'checkout-block':
case 'cart-block':
return $smart_button_enabled_for_current_location;
case 'product':
return $smart_button_enabled_for_current_location || $messaging_enabled_for_current_location || $smart_button_enabled_for_mini_cart;
return $smart_button_enabled_for_current_location || $smart_button_enabled_for_mini_cart;
default:
return $smart_button_enabled_for_mini_cart;
}
}
/**
* Determines whether the Pay Later messages component should be loaded.
*/
public function should_load_messages() : bool {
$pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
if ( ! $pcp_gateway_enabled ) {
return false;
}
if ( ! $this->messages_apply->for_country() || $this->is_free_trial_cart() ) {
return false;
}
$location = $this->location();
$messaging_enabled_for_current_location = $this->settings_status->is_pay_later_messaging_enabled_for_location( $location );
switch ( $location ) {
case 'checkout':
case 'cart':
case 'pay-now':
case 'product':
case 'shop':
case 'home':
return $messaging_enabled_for_current_location;
default:
return false;
}
}
/**
* Whether DCC fields can be rendered.
*/
@ -630,8 +652,24 @@ class SmartButton implements SmartButtonInterface {
// The wrapper is needed for the loading spinner,
// otherwise jQuery block() prevents buttons rendering.
echo '<div class="ppc-button-wrapper">';
$hook_gateway_id = str_replace( '-', '_', $gateway_id );
/**
* A hook executed after rendering of the opening tag for the PCP wrapper (before the inner wrapper for the buttons).
*
* For the PayPal gateway the hook name is ppcp_start_button_wrapper_ppcp_gateway.
*/
do_action( 'ppcp_start_button_wrapper_' . $hook_gateway_id );
echo '<div id="ppc-button-' . esc_attr( $gateway_id ) . '"></div>';
/**
* A hook executed before rendering of the closing tag for the PCP wrapper (before the inner wrapper for the buttons).
*
* For the PayPal gateway the hook name is ppcp_end_button_wrapper_ppcp_gateway.
*/
do_action( 'ppcp_end_button_wrapper_' . $hook_gateway_id );
if ( null !== $action_name ) {
do_action( $action_name );
}
@ -646,8 +684,10 @@ class SmartButton implements SmartButtonInterface {
$product = wc_get_product();
$location = $this->location();
if (
! is_checkout() && is_a( $product, WC_Product::class )
$location === 'product' && is_a( $product, WC_Product::class )
/**
* The filter returning true if PayPal buttons can be rendered, or false otherwise.
*/
@ -663,24 +703,47 @@ class SmartButton implements SmartButtonInterface {
* The values for the credit messaging.
*
* @return array
* @throws NotFoundException When a setting was not found.
*/
private function message_values(): array {
if ( ! $this->settings_status->is_pay_later_messaging_enabled() ) {
return array();
}
$placement = is_checkout() ? 'payment' : ( is_cart() ? 'cart' : 'product' );
$product = wc_get_product();
$amount = ( is_a( $product, WC_Product::class ) ) ? wc_get_price_including_tax( $product ) : 0;
$location = $this->location();
switch ( $location ) {
case 'checkout':
case 'checkout-block':
case 'pay-now':
$placement = 'payment';
break;
case 'cart':
case 'cart-block':
$placement = 'cart';
break;
case 'product':
$placement = 'product';
break;
case 'shop':
$placement = 'product-list';
break;
case 'home':
$placement = 'home';
break;
default:
$placement = 'payment';
break;
}
$product = wc_get_product();
$amount = ( is_a( $product, WC_Product::class ) ) ? wc_get_price_including_tax( $product ) : 0;
if ( is_checkout() || is_cart() ) {
$amount = WC()->cart->get_total( 'raw' );
}
$styling_per_location = $this->settings->has( 'pay_later_enable_styling_per_messaging_location' ) && $this->settings->get( 'pay_later_enable_styling_per_messaging_location' );
$per_location = is_checkout() ? 'checkout' : ( is_cart() ? 'cart' : 'product' );
$location = $styling_per_location ? $per_location : 'general';
$location = $styling_per_location ? $location : 'general';
$setting_name_prefix = "pay_later_{$location}_message";
$layout = $this->settings->has( "{$setting_name_prefix}_layout" ) ? $this->settings->get( "{$setting_name_prefix}_layout" ) : 'text';
@ -1163,10 +1226,7 @@ class SmartButton implements SmartButtonInterface {
$components[] = 'buttons';
$components[] = 'funding-eligibility';
}
if (
$this->messages_apply->for_country()
&& ! $this->is_free_trial_cart()
) {
if ( $this->should_load_messages() ) {
$components[] = 'messages';
}
if ( $this->dcc_is_enabled() ) {
@ -1300,6 +1360,35 @@ class SmartButton implements SmartButtonInterface {
return (string) apply_filters( 'woocommerce_paypal_payments_pay_order_dcc_renderer_hook', 'woocommerce_pay_order_after_submit' );
}
/**
* Returns the action name that will be used for rendering Pay Later messages.
*
* @param string $location The location name like 'checkout', 'shop'. See render_message_wrapper_registrar.
* @param string $default_hook The default name of the hook.
* @param int $default_priority The default priority of the hook.
* @return array An array with 'name' and 'priority' keys.
*/
private function messages_renderer_hook( string $location, string $default_hook, int $default_priority ): array {
/**
* The filter returning the action name that will be used for rendering Pay Later messages.
*/
$hook = (string) apply_filters(
"woocommerce_paypal_payments_${location}_messages_renderer_hook",
$default_hook
);
/**
* The filter returning the action priority that will be used for rendering Pay Later messages.
*/
$priority = (int) apply_filters(
"woocommerce_paypal_payments_${location}_messages_renderer_priority",
$default_priority
);
return array(
'name' => $hook,
'priority' => $priority,
);
}
/**
* Returns action name that PayPal button will use for rendering next to Proceed to checkout button (normally displayed in cart).
*

View file

@ -12,6 +12,27 @@ namespace WooCommerce\PayPalCommerce\Button\Helper;
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
trait ContextTrait {
/**
* Checks WC is_checkout() + WC checkout ajax requests.
*/
private function is_checkout(): bool {
if ( is_checkout() ) {
return true;
}
/**
* The filter returning whether to detect WC checkout ajax requests.
*/
if ( apply_filters( 'ppcp_check_ajax_checkout', true ) ) {
// phpcs:ignore WordPress.Security
$wc_ajax = $_GET['wc-ajax'] ?? '';
if ( in_array( $wc_ajax, array( 'update_order_review' ), true ) ) {
return true;
}
}
return false;
}
/**
* The current context.
@ -23,7 +44,7 @@ trait ContextTrait {
// Do this check here instead of reordering outside conditions.
// In order to have more control over the context.
if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) {
if ( $this->is_checkout() && ! $this->is_paypal_continuation() ) {
return 'checkout';
}
@ -47,13 +68,35 @@ trait ContextTrait {
return 'checkout-block';
}
if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) {
if ( $this->is_checkout() && ! $this->is_paypal_continuation() ) {
return 'checkout';
}
return 'mini-cart';
}
/**
* The current location.
*
* @return string
*/
protected function location(): string {
$context = $this->context();
if ( $context !== 'mini-cart' ) {
return $context;
}
if ( is_shop() ) {
return 'shop';
}
if ( is_front_page() ) {
return 'home';
}
return '';
}
/**
* Checks if PayPal payment was already initiated (on the product or cart pages).
*

View file

@ -1,7 +1,7 @@
document.addEventListener(
'DOMContentLoaded',
() => {
const payLaterMessagingSelectableLocations = ['product', 'cart', 'checkout'];
const payLaterMessagingSelectableLocations = ['product', 'cart', 'checkout', 'shop', 'home'];
const payLaterMessagingAllLocations = payLaterMessagingSelectableLocations.concat('general');
const payLaterMessagingLocationsSelector = '#field-pay_later_messaging_locations';
const payLaterMessagingLocationsSelect = payLaterMessagingLocationsSelector + ' select';
@ -9,7 +9,7 @@ document.addEventListener(
const smartButtonLocationsSelector = '#field-smart_button_locations';
const smartButtonLocationsSelect = smartButtonLocationsSelector + ' select';
const smartButtonSelectableLocations = payLaterMessagingSelectableLocations.concat('mini-cart');
const smartButtonSelectableLocations = ['product', 'cart', 'checkout', 'mini-cart'];
const groupToggle = (selector, group) => {
const toggleElement = document.querySelector(selector);

View file

@ -172,11 +172,16 @@ document.addEventListener(
function createMessagesPreview(settingsCallback) {
const render = (settings) => {
const wrapper = document.querySelector(settings.wrapper);
let wrapper = document.querySelector(settings.wrapper);
if (!wrapper) {
return;
}
wrapper.innerHTML = '';
// looks like .innerHTML = '' is not enough, PayPal somehow renders with old style
const parent = wrapper.parentElement;
parent.removeChild(wrapper);
wrapper = document.createElement('div');
wrapper.setAttribute('id', settings.wrapper.replace('#', ''));
parent.appendChild(wrapper);
const messageRenderer = new MessageRenderer(settings);
@ -269,7 +274,7 @@ document.addEventListener(
}, 1000));
loadPaypalScript(oldScriptSettings, () => {
const payLaterMessagingLocations = ['product', 'cart', 'checkout', 'general'];
const payLaterMessagingLocations = ['product', 'cart', 'checkout', 'shop', 'home', 'general'];
const paypalButtonLocations = ['product', 'cart', 'checkout', 'mini-cart', 'general'];
paypalButtonLocations.forEach((location) => {

View file

@ -1354,7 +1354,13 @@ return array(
'wcgateway.settings.pay-later.messaging-locations' => static function( ContainerInterface $container ): array {
$button_locations = $container->get( 'wcgateway.button.locations' );
unset( $button_locations['mini-cart'] );
return $button_locations;
return array_merge(
$button_locations,
array(
'shop' => __( 'Shop', 'woocommerce-paypal-payments' ),
'home' => __( 'Home', 'woocommerce-paypal-payments' ),
)
);
},
'wcgateway.button.default-locations' => static function( ContainerInterface $container ): array {
return array_keys( $container->get( 'wcgateway.settings.pay-later.messaging-locations' ) );

View file

@ -623,6 +623,254 @@ return function ( ContainerInterface $container, array $fields ): array {
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
// Shop.
'pay_later_shop_messaging_heading' => array(
'heading' => __( 'Pay Later Messaging on the Shop page', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_layout' => array(
'title' => __( 'Shop Messaging Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'text',
'desc_tip' => true,
'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ),
'options' => array(
'text' => __( 'Text', 'woocommerce-paypal-payments' ),
'flex' => __( 'Banner', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_logo' => array(
'title' => __( 'Shop Messaging Logo', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'inline',
'desc_tip' => true,
'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'primary' => __( 'Primary', 'woocommerce-paypal-payments' ),
'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ),
'inline' => __( 'Inline', 'woocommerce-paypal-payments' ),
'none' => __( 'None', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_position' => array(
'title' => __( 'Shop Messaging Logo Position', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'left',
'desc_tip' => true,
'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'left' => __( 'Left', 'woocommerce-paypal-payments' ),
'right' => __( 'Right', 'woocommerce-paypal-payments' ),
'top' => __( 'Top', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_color' => array(
'title' => __( 'Shop Messaging Text Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'black',
'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_flex_color' => array(
'title' => __( 'Shop Messaging Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => $default_messaging_flex_color,
'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Banner is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ),
'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ),
'gray' => __( 'Gray', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_flex_ratio' => array(
'title' => __( 'Shop Messaging Ratio', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => '8x1',
'desc_tip' => true,
'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Banner is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'1x1' => __( '1x1', 'woocommerce-paypal-payments' ),
'1x4' => __( '1x4', 'woocommerce-paypal-payments' ),
'8x1' => __( '8x1', 'woocommerce-paypal-payments' ),
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_shop_message_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpShopMessagePreview', 'message', $messaging_message ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
// Home.
'pay_later_home_messaging_heading' => array(
'heading' => __( 'Pay Later Messaging on the Home page', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_layout' => array(
'title' => __( 'Home Messaging Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'text',
'desc_tip' => true,
'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ),
'options' => array(
'text' => __( 'Text', 'woocommerce-paypal-payments' ),
'flex' => __( 'Banner', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_logo' => array(
'title' => __( 'Home Messaging Logo', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'inline',
'desc_tip' => true,
'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'primary' => __( 'Primary', 'woocommerce-paypal-payments' ),
'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ),
'inline' => __( 'Inline', 'woocommerce-paypal-payments' ),
'none' => __( 'None', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_position' => array(
'title' => __( 'Home Messaging Logo Position', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'left',
'desc_tip' => true,
'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'left' => __( 'Left', 'woocommerce-paypal-payments' ),
'right' => __( 'Right', 'woocommerce-paypal-payments' ),
'top' => __( 'Top', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_color' => array(
'title' => __( 'Home Messaging Text Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'black',
'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_flex_color' => array(
'title' => __( 'Home Messaging Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => $default_messaging_flex_color,
'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Banner is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ),
'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ),
'gray' => __( 'Gray', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_flex_ratio' => array(
'title' => __( 'Home Messaging Ratio', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => '8x1',
'desc_tip' => true,
'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Banner is used.', 'woocommerce-paypal-payments' ),
'options' => array(
'1x1' => __( '1x1', 'woocommerce-paypal-payments' ),
'1x4' => __( '1x4', 'woocommerce-paypal-payments' ),
'8x1' => __( '8x1', 'woocommerce-paypal-payments' ),
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_home_message_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpHomeMessagePreview', 'message', $messaging_message ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
);
return array_merge( $fields, $pay_later_fields );