Add button and message previews

This commit is contained in:
Narek Zakarian 2022-11-02 17:34:53 +04:00
parent 510cb4db49
commit cc1fb62a6f
3 changed files with 446 additions and 385 deletions

View file

@ -351,7 +351,7 @@ class SmartButton implements SmartButtonInterface {
* @throws NotFoundException When a setting was not found. * @throws NotFoundException When a setting was not found.
*/ */
private function render_message_wrapper_registrar(): bool { private function render_message_wrapper_registrar(): bool {
if ( ! $this->settings_status->pay_later_messaging_is_enabled() ) { if ( ! $this->settings_status->is_pay_later_messaging_enabled() ) {
return false; return false;
} }
@ -603,7 +603,7 @@ class SmartButton implements SmartButtonInterface {
* @throws NotFoundException When a setting was not found. * @throws NotFoundException When a setting was not found.
*/ */
private function message_values(): array { private function message_values(): array {
if ( ! $this->settings_status->pay_later_messaging_is_enabled() ) { if ( ! $this->settings_status->is_pay_later_messaging_enabled() ) {
return array(); return array();
} }
@ -954,7 +954,7 @@ class SmartButton implements SmartButtonInterface {
$disable_funding = $all_sources; $disable_funding = $all_sources;
} }
if ( ! $this->settings_status->pay_later_button_is_enabled_for_context( $this->context() ) ) { if ( ! $this->settings_status->is_pay_later_button_enabled_for_context( $this->context() ) ) {
$disable_funding[] = 'credit'; $disable_funding[] = 'credit';
} }
@ -963,7 +963,7 @@ class SmartButton implements SmartButtonInterface {
} }
$enable_funding = array( 'venmo' ); $enable_funding = array( 'venmo' );
if ( $this->settings_status->pay_later_messaging_is_enabled() || ! in_array( 'credit', $disable_funding, true ) ) { if ( $this->settings_status->is_pay_later_messaging_enabled() || ! in_array( 'credit', $disable_funding, true ) ) {
$enable_funding[] = 'paylater'; $enable_funding[] = 'paylater';
} }
@ -1061,7 +1061,7 @@ class SmartButton implements SmartButtonInterface {
$this->context() === 'product' $this->context() === 'product'
&& ( && (
( $this->settings->has( 'button_product_enabled' ) && $this->settings->get( 'button_product_enabled' ) ) || ( $this->settings->has( 'button_product_enabled' ) && $this->settings->get( 'button_product_enabled' ) ) ||
( $this->settings_status->pay_later_messaging_is_enabled_for_location( 'product' ) ) ( $this->settings_status->is_pay_later_messaging_enabled_for_location( 'product' ) )
) )
) { ) {
$load_buttons = true; $load_buttons = true;
@ -1077,7 +1077,7 @@ class SmartButton implements SmartButtonInterface {
$this->context() === 'cart' $this->context() === 'cart'
&& ( && (
( $this->settings->has( 'button_cart_enabled' ) && $this->settings->get( 'button_cart_enabled' ) ) || ( $this->settings->has( 'button_cart_enabled' ) && $this->settings->get( 'button_cart_enabled' ) ) ||
( $this->settings_status->pay_later_messaging_is_enabled_for_location( 'cart' ) ) ( $this->settings_status->is_pay_later_messaging_enabled_for_location( 'cart' ) )
) )
) { ) {
$load_buttons = true; $load_buttons = true;

View file

@ -26,39 +26,54 @@ return function ( ContainerInterface $container, array $fields ): array {
return $fields; return $fields;
} }
$settings = $container->get( 'wcgateway.settings' ); $settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings ); assert( $settings instanceof Settings );
$vault_enabled = $settings->has( 'vault_enabled' ) && $settings->get( 'vault_enabled' ); $vault_enabled = $settings->has( 'vault_enabled' ) && $settings->get( 'vault_enabled' );
$pay_later_messaging_enabled_label = $vault_enabled $pay_later_messaging_enabled_label = $vault_enabled
? __( "You have PayPal vaulting enabled, that's why Pay Later options are unavailable now. You cannot use both features at the same time.", 'woocommerce-paypal-payments' ) ? __( "You have PayPal vaulting enabled, that's why Pay Later options are unavailable now. You cannot use both features at the same time.", 'woocommerce-paypal-payments' )
: __( 'Enabled', 'woocommerce-paypal-payments' ); : __( 'Enabled', 'woocommerce-paypal-payments' );
$render_preview_element = function ( string $id, string $type ): string {
return '
<div class="ppcp-' . $type . '-preview pay-later">
<h4>' . __( 'Preview', 'woocommerce-paypal-payments' ) . '</h4>
<div id="' . $id . '" class="ppcp-' . $type . '-preview-inner"></div>
</div>';
};
$pay_later_fields = array( $pay_later_fields = array(
'pay_later_button_enabled' => array( 'pay_later_button_enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ), 'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'label' => esc_html($pay_later_messaging_enabled_label), 'label' => esc_html( $pay_later_messaging_enabled_label ),
'default' => true, 'default' => true,
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
'input_class' => $vault_enabled ? array( 'ppcp-disabled-checkbox' ) : array(), 'input_class' => $vault_enabled ? array( 'ppcp-disabled-checkbox' ) : array(),
),
'pay_later_button_locations' => array(
'title' => __( 'Pay Later Button Locations', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => array(),
'desc_tip' => false,
'description' => __( 'Example description', 'woocommerce-paypal-payments' ),
'options' => $container->get( 'wcgateway.settings.pay-later.button-locations' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
'pay_later_button_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpPayLaterButtonPreview', 'button' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_button_locations' => array(
'title' => __( 'Pay Later Button Locations', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => array(),
'desc_tip' => false,
'description' => __( 'Example description', 'woocommerce-paypal-payments' ),
'options' => $container->get( 'wcgateway.settings.pay-later.button-locations' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
// Messaging. // Messaging.
'pay_later_messaging_heading' => array( 'pay_later_messaging_heading' => array(
@ -69,16 +84,16 @@ return function ( ContainerInterface $container, array $fields ): array {
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
'description' => __( 'Example description.', 'woocommerce-paypal-payments' ), 'description' => __( 'Example description.', 'woocommerce-paypal-payments' ),
), ),
'pay_later_messaging_enabled' => array( 'pay_later_messaging_enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ), 'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'label' => esc_html($pay_later_messaging_enabled_label), 'label' => esc_html( $pay_later_messaging_enabled_label ),
'default' => true, 'default' => true,
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
'input_class' => $vault_enabled ? array( 'ppcp-disabled-checkbox' ) : array(), 'input_class' => $vault_enabled ? array( 'ppcp-disabled-checkbox' ) : array(),
), ),
'pay_later_messaging_locations' => array( 'pay_later_messaging_locations' => array(
'title' => __( 'Pay Later Messaging Locations', 'woocommerce-paypal-payments' ), 'title' => __( 'Pay Later Messaging Locations', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect', 'type' => 'ppcp-multiselect',
@ -209,357 +224,385 @@ return function ( ContainerInterface $container, array $fields ): array {
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_general_message_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpGeneralMessagePreview', 'message' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
//Single product // Single product
'pay_later_product_messaging_heading' => array( 'pay_later_product_messaging_heading' => array(
'heading' => __( 'Pay Later Messaging on Single Product', 'woocommerce-paypal-payments' ), 'heading' => __( 'Pay Later Messaging on Single Product', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array(), 'requirements' => array(),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_layout' => array( 'pay_later_product_message_layout' => array(
'title' => __( 'Single Product Messaging Layout', 'woocommerce-paypal-payments' ), 'title' => __( 'Single Product Messaging Layout', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'text', 'default' => 'text',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ), 'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'text' => __( 'Text', 'woocommerce-paypal-payments' ), 'text' => __( 'Text', 'woocommerce-paypal-payments' ),
'flex' => __( 'Flex', 'woocommerce-paypal-payments' ), 'flex' => __( 'Flex', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_logo' => array( 'pay_later_product_message_logo' => array(
'title' => __( 'Single Product Messaging Logo', 'woocommerce-paypal-payments' ), 'title' => __( 'Single Product Messaging Logo', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'primary', 'default' => 'primary',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'primary' => __( 'Primary', 'woocommerce-paypal-payments' ), 'primary' => __( 'Primary', 'woocommerce-paypal-payments' ),
'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ), 'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ),
'inline' => __( 'Inline', 'woocommerce-paypal-payments' ), 'inline' => __( 'Inline', 'woocommerce-paypal-payments' ),
'none' => __( 'None', 'woocommerce-paypal-payments' ), 'none' => __( 'None', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_position' => array( 'pay_later_product_message_position' => array(
'title' => __( 'Single Product Messaging Logo Position', 'woocommerce-paypal-payments' ), 'title' => __( 'Single Product Messaging Logo Position', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'left', 'default' => 'left',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'left' => __( 'Left', 'woocommerce-paypal-payments' ), 'left' => __( 'Left', 'woocommerce-paypal-payments' ),
'right' => __( 'Right', 'woocommerce-paypal-payments' ), 'right' => __( 'Right', 'woocommerce-paypal-payments' ),
'top' => __( 'Top', 'woocommerce-paypal-payments' ), 'top' => __( 'Top', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_color' => array( 'pay_later_product_message_color' => array(
'title' => __( 'Single Product Messaging Text Color', 'woocommerce-paypal-payments' ), 'title' => __( 'Single Product Messaging Text Color', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'black', 'default' => 'black',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ), 'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ), 'white' => __( 'White', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ), 'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ), 'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_flex_color' => array( 'pay_later_product_message_flex_color' => array(
'title' => __( 'Single Product Messaging Color', 'woocommerce-paypal-payments' ), 'title' => __( 'Single Product Messaging Color', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'blue', 'default' => 'blue',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The color of the text. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ), 'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ), 'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ), 'white' => __( 'White', 'woocommerce-paypal-payments' ),
'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ), 'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ),
'gray' => __( 'Gray', 'woocommerce-paypal-payments' ), 'gray' => __( 'Gray', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ), 'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ), 'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_flex_ratio' => array( 'pay_later_product_message_flex_ratio' => array(
'title' => __( 'Single Product Messaging Ratio', 'woocommerce-paypal-payments' ), 'title' => __( 'Single Product Messaging Ratio', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => '1x1', 'default' => '1x1',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'1x1' => __( '1x1', 'woocommerce-paypal-payments' ), '1x1' => __( '1x1', 'woocommerce-paypal-payments' ),
'1x4' => __( '1x4', 'woocommerce-paypal-payments' ), '1x4' => __( '1x4', 'woocommerce-paypal-payments' ),
'8x1' => __( '8x1', 'woocommerce-paypal-payments' ), '8x1' => __( '8x1', 'woocommerce-paypal-payments' ),
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ), '20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_product_message_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpProductMessagePreview', 'message' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
//Cart // Cart
'pay_later_cart_messaging_heading' => array( 'pay_later_cart_messaging_heading' => array(
'heading' => __( 'Pay Later Messaging on Cart', 'woocommerce-paypal-payments' ), 'heading' => __( 'Pay Later Messaging on Cart', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array(), 'requirements' => array(),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_layout' => array( 'pay_later_cart_message_layout' => array(
'title' => __( 'Cart Messaging Layout', 'woocommerce-paypal-payments' ), 'title' => __( 'Cart Messaging Layout', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'text', 'default' => 'text',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ), 'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'text' => __( 'Text', 'woocommerce-paypal-payments' ), 'text' => __( 'Text', 'woocommerce-paypal-payments' ),
'flex' => __( 'Flex', 'woocommerce-paypal-payments' ), 'flex' => __( 'Flex', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_logo' => array( 'pay_later_cart_message_logo' => array(
'title' => __( 'Cart Messaging Logo', 'woocommerce-paypal-payments' ), 'title' => __( 'Cart Messaging Logo', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'primary', 'default' => 'primary',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'primary' => __( 'Primary', 'woocommerce-paypal-payments' ), 'primary' => __( 'Primary', 'woocommerce-paypal-payments' ),
'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ), 'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ),
'inline' => __( 'Inline', 'woocommerce-paypal-payments' ), 'inline' => __( 'Inline', 'woocommerce-paypal-payments' ),
'none' => __( 'None', 'woocommerce-paypal-payments' ), 'none' => __( 'None', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_position' => array( 'pay_later_cart_message_position' => array(
'title' => __( 'Cart Messaging Logo Position', 'woocommerce-paypal-payments' ), 'title' => __( 'Cart Messaging Logo Position', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'left', 'default' => 'left',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'left' => __( 'Left', 'woocommerce-paypal-payments' ), 'left' => __( 'Left', 'woocommerce-paypal-payments' ),
'right' => __( 'Right', 'woocommerce-paypal-payments' ), 'right' => __( 'Right', 'woocommerce-paypal-payments' ),
'top' => __( 'Top', 'woocommerce-paypal-payments' ), 'top' => __( 'Top', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_color' => array( 'pay_later_cart_message_color' => array(
'title' => __( 'Cart Messaging Text Color', 'woocommerce-paypal-payments' ), 'title' => __( 'Cart Messaging Text Color', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'black', 'default' => 'black',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ), 'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ), 'white' => __( 'White', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ), 'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ), 'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_flex_color' => array( 'pay_later_cart_message_flex_color' => array(
'title' => __( 'Cart Messaging Color', 'woocommerce-paypal-payments' ), 'title' => __( 'Cart Messaging Color', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'blue', 'default' => 'blue',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The color of the text. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ), 'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ), 'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ), 'white' => __( 'White', 'woocommerce-paypal-payments' ),
'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ), 'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ),
'gray' => __( 'Gray', 'woocommerce-paypal-payments' ), 'gray' => __( 'Gray', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ), 'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ), 'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_flex_ratio' => array( 'pay_later_cart_message_flex_ratio' => array(
'title' => __( 'Cart Messaging Ratio', 'woocommerce-paypal-payments' ), 'title' => __( 'Cart Messaging Ratio', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => '1x1', 'default' => '1x1',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'1x1' => __( '1x1', 'woocommerce-paypal-payments' ), '1x1' => __( '1x1', 'woocommerce-paypal-payments' ),
'1x4' => __( '1x4', 'woocommerce-paypal-payments' ), '1x4' => __( '1x4', 'woocommerce-paypal-payments' ),
'8x1' => __( '8x1', 'woocommerce-paypal-payments' ), '8x1' => __( '8x1', 'woocommerce-paypal-payments' ),
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ), '20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_cart_message_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCartMessagePreview', 'message' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
//Checkout // Checkout
'pay_later_checkout_messaging_heading' => array( 'pay_later_checkout_messaging_heading' => array(
'heading' => __( 'Pay Later Messaging on Checkout', 'woocommerce-paypal-payments' ), 'heading' => __( 'Pay Later Messaging on Checkout', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array(), 'requirements' => array(),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_layout' => array( 'pay_later_checkout_message_layout' => array(
'title' => __( 'Checkout Messaging Layout', 'woocommerce-paypal-payments' ), 'title' => __( 'Checkout Messaging Layout', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'text', 'default' => 'text',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ), 'description' => __( 'The layout of the message.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'text' => __( 'Text', 'woocommerce-paypal-payments' ), 'text' => __( 'Text', 'woocommerce-paypal-payments' ),
'flex' => __( 'Flex', 'woocommerce-paypal-payments' ), 'flex' => __( 'Flex', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_logo' => array( 'pay_later_checkout_message_logo' => array(
'title' => __( 'Checkout Messaging Logo', 'woocommerce-paypal-payments' ), 'title' => __( 'Checkout Messaging Logo', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'primary', 'default' => 'primary',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'What logo the text message contains. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'primary' => __( 'Primary', 'woocommerce-paypal-payments' ), 'primary' => __( 'Primary', 'woocommerce-paypal-payments' ),
'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ), 'alternative' => __( 'Alternative', 'woocommerce-paypal-payments' ),
'inline' => __( 'Inline', 'woocommerce-paypal-payments' ), 'inline' => __( 'Inline', 'woocommerce-paypal-payments' ),
'none' => __( 'None', 'woocommerce-paypal-payments' ), 'none' => __( 'None', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_position' => array( 'pay_later_checkout_message_position' => array(
'title' => __( 'Checkout Messaging Logo Position', 'woocommerce-paypal-payments' ), 'title' => __( 'Checkout Messaging Logo Position', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'left', 'default' => 'left',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The position of the logo. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'left' => __( 'Left', 'woocommerce-paypal-payments' ), 'left' => __( 'Left', 'woocommerce-paypal-payments' ),
'right' => __( 'Right', 'woocommerce-paypal-payments' ), 'right' => __( 'Right', 'woocommerce-paypal-payments' ),
'top' => __( 'Top', 'woocommerce-paypal-payments' ), 'top' => __( 'Top', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_color' => array( 'pay_later_checkout_message_color' => array(
'title' => __( 'Checkout Messaging Text Color', 'woocommerce-paypal-payments' ), 'title' => __( 'Checkout Messaging Text Color', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'black', 'default' => 'black',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The color of the text. Only applicable, when the layout style Text is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ), 'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ), 'white' => __( 'White', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ), 'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ), 'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_flex_color' => array( 'pay_later_checkout_message_flex_color' => array(
'title' => __( 'Checkout Messaging Color', 'woocommerce-paypal-payments' ), 'title' => __( 'Checkout Messaging Color', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => 'blue', 'default' => 'blue',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The color of the text. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The color of the text. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ), 'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ), 'black' => __( 'Black', 'woocommerce-paypal-payments' ),
'white' => __( 'White', 'woocommerce-paypal-payments' ), 'white' => __( 'White', 'woocommerce-paypal-payments' ),
'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ), 'white-no-border' => __( 'White no border', 'woocommerce-paypal-payments' ),
'gray' => __( 'Gray', 'woocommerce-paypal-payments' ), 'gray' => __( 'Gray', 'woocommerce-paypal-payments' ),
'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ), 'monochrome' => __( 'Monochrome', 'woocommerce-paypal-payments' ),
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ), 'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_flex_ratio' => array( 'pay_later_checkout_message_flex_ratio' => array(
'title' => __( 'Checkout Messaging Ratio', 'woocommerce-paypal-payments' ), 'title' => __( 'Checkout Messaging Ratio', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
'default' => '1x1', 'default' => '1x1',
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ), 'description' => __( 'The width/height ratio of the banner. Only applicable, when the layout style Flex is used.', 'woocommerce-paypal-payments' ),
'options' => array( 'options' => array(
'1x1' => __( '1x1', 'woocommerce-paypal-payments' ), '1x1' => __( '1x1', 'woocommerce-paypal-payments' ),
'1x4' => __( '1x4', 'woocommerce-paypal-payments' ), '1x4' => __( '1x4', 'woocommerce-paypal-payments' ),
'8x1' => __( '8x1', 'woocommerce-paypal-payments' ), '8x1' => __( '8x1', 'woocommerce-paypal-payments' ),
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ), '20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
), ),
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ), 'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID, 'gateway' => Settings::PAY_LATER_TAB_ID,
), ),
'pay_later_checkout_message_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCheckoutMessagePreview', 'message' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'messages' ),
'gateway' => Settings::PAY_LATER_TAB_ID,
),
); );
return array_merge( $fields, $pay_later_fields ); return array_merge( $fields, $pay_later_fields );

View file

@ -988,6 +988,15 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'button_product_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpProductButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Cart settings. // Cart settings.
'button_cart_heading' => array( 'button_cart_heading' => array(
@ -1130,6 +1139,15 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'button_cart_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCartButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Mini cart settings. // Mini cart settings.
'button_mini-cart_heading' => array( 'button_mini-cart_heading' => array(