mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Put messaging configurator on top of the page
This commit is contained in:
parent
55227e6005
commit
f82b0be0e4
2 changed files with 53 additions and 46 deletions
|
@ -1,10 +1,18 @@
|
||||||
document.addEventListener( 'DOMContentLoaded', () => {
|
document.addEventListener( 'DOMContentLoaded', () => {
|
||||||
const form = document.querySelector('#mainform');
|
const form = document.querySelector('#mainform');
|
||||||
const table = form.querySelector('.form-table');
|
const table = form.querySelector('.form-table');
|
||||||
|
const headingRow = table.querySelector('#field-pay_later_messaging_heading');
|
||||||
const saveChangesButton = form.querySelector('.woocommerce-save-button');
|
const saveChangesButton = form.querySelector('.woocommerce-save-button');
|
||||||
const publishButtonClassName = PcpPayLaterConfigurator.publishButtonClassName;
|
const publishButtonClassName = PcpPayLaterConfigurator.publishButtonClassName;
|
||||||
|
|
||||||
table.insertAdjacentHTML('afterend', '<div id="messaging-configurator"></div>');
|
const tempContainer = document.createElement('div');
|
||||||
|
tempContainer.innerHTML = `<div id='messaging-configurator'></div>`;
|
||||||
|
|
||||||
|
// Get the new row element from the container
|
||||||
|
const newRow = tempContainer.firstChild;
|
||||||
|
|
||||||
|
// Insert the new row after the headingRow
|
||||||
|
headingRow.parentNode.insertBefore(newRow, headingRow.nextSibling);
|
||||||
|
|
||||||
|
|
||||||
saveChangesButton.addEventListener('click', () => {
|
saveChangesButton.addEventListener('click', () => {
|
||||||
|
|
|
@ -44,51 +44,6 @@ return function ( ContainerInterface $container, array $fields ): array {
|
||||||
};
|
};
|
||||||
|
|
||||||
$pay_later_fields = array(
|
$pay_later_fields = array(
|
||||||
'pay_later_button_heading' => array(
|
|
||||||
'heading' => __( 'Pay Later Button', 'woocommerce-paypal-payments' ),
|
|
||||||
'type' => 'ppcp-heading',
|
|
||||||
'screens' => array( State::STATE_ONBOARDED ),
|
|
||||||
'requirements' => array( 'messages' ),
|
|
||||||
'gateway' => Settings::PAY_LATER_TAB_ID,
|
|
||||||
'description' => sprintf(
|
|
||||||
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
|
|
||||||
__( 'When enabled, a %1$sPay Later button%2$s is displayed for eligible customers.%3$sPayPal buttons must be enabled to display the Pay Later button.', 'woocommerce-paypal-payments' ),
|
|
||||||
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#pay-later-buttons" target="_blank">',
|
|
||||||
'</a>',
|
|
||||||
'</ br>'
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'pay_later_button_enabled' => array(
|
|
||||||
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'label' => esc_html( $pay_later_messaging_enabled_label ),
|
|
||||||
'default' => true,
|
|
||||||
'screens' => array( State::STATE_ONBOARDED ),
|
|
||||||
'requirements' => array( 'messages' ),
|
|
||||||
'gateway' => Settings::PAY_LATER_TAB_ID,
|
|
||||||
'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' => $container->get( 'wcgateway.settings.pay-later.default-button-locations' ),
|
|
||||||
'desc_tip' => false,
|
|
||||||
'description' => __( 'Select where the Pay Later button should be displayed.', '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', $button_message ),
|
|
||||||
'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(
|
||||||
'heading' => __( 'Pay Later Messaging', 'woocommerce-paypal-payments' ),
|
'heading' => __( 'Pay Later Messaging', 'woocommerce-paypal-payments' ),
|
||||||
|
@ -871,6 +826,50 @@ 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_button_heading' => array(
|
||||||
|
'heading' => __( 'Pay Later Button', 'woocommerce-paypal-payments' ),
|
||||||
|
'type' => 'ppcp-heading',
|
||||||
|
'screens' => array( State::STATE_ONBOARDED ),
|
||||||
|
'requirements' => array( 'messages' ),
|
||||||
|
'gateway' => Settings::PAY_LATER_TAB_ID,
|
||||||
|
'description' => sprintf(
|
||||||
|
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
|
||||||
|
__( 'When enabled, a %1$sPay Later button%2$s is displayed for eligible customers.%3$sPayPal buttons must be enabled to display the Pay Later button.', 'woocommerce-paypal-payments' ),
|
||||||
|
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#pay-later-buttons" target="_blank">',
|
||||||
|
'</a>',
|
||||||
|
'</ br>'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'pay_later_button_enabled' => array(
|
||||||
|
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'label' => esc_html( $pay_later_messaging_enabled_label ),
|
||||||
|
'default' => true,
|
||||||
|
'screens' => array( State::STATE_ONBOARDED ),
|
||||||
|
'requirements' => array( 'messages' ),
|
||||||
|
'gateway' => Settings::PAY_LATER_TAB_ID,
|
||||||
|
'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' => $container->get( 'wcgateway.settings.pay-later.default-button-locations' ),
|
||||||
|
'desc_tip' => false,
|
||||||
|
'description' => __( 'Select where the Pay Later button should be displayed.', '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', $button_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 );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue