Add final review checkbox

This commit is contained in:
Alex P 2023-04-18 16:55:01 +03:00
parent 0d8f86eefa
commit f435796cbe
No known key found for this signature in database
GPG key ID: 54487A734A204D71
2 changed files with 38 additions and 0 deletions

View file

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Blocks; namespace WooCommerce\PayPalCommerce\Blocks;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array( return array(
@ -26,4 +27,30 @@ return array(
unset( $locations['cart-block'] ); unset( $locations['cart-block'] );
return $locations; return $locations;
}, },
'wcgateway.settings.fields' => function ( ContainerInterface $container, array $fields ): array {
$insert_after = function( array $array, string $key, array $new ): array {
$keys = array_keys( $array );
$index = array_search( $key, $keys, true );
$pos = false === $index ? count( $array ) : $index + 1;
return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
};
return $insert_after(
$fields,
'smart_button_enable_styling_per_location',
array(
'blocks_no_final_review' => array(
'title' => __( 'Block Express payments Final Review', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Require customers to confirm Block Express payments on the Checkout page. If disabled, the Checkout page is skipped for Block Express payments.', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => 'paypal',
),
)
);
},
); );

View file

@ -19,6 +19,17 @@ import {setVisibleByClass, isVisible} from "../../../ppcp-button/resources/js/mo
const form = jQuery('#mainform'); const form = jQuery('#mainform');
const noReviewChk = document.querySelector('#ppcp-blocks_no_final_review');
if (noReviewChk) {
noReviewChk.addEventListener('click', (e) => {
if (!noReviewChk.checked) {
if (!window.confirm('Are you sure you want to disable the final review on the Checkout page for Block Express payments?')) {
noReviewChk.checked = true;
}
}
});
}
const payLaterButtonInput = document.querySelector('#ppcp-pay_later_button_enabled'); const payLaterButtonInput = document.querySelector('#ppcp-pay_later_button_enabled');
if (payLaterButtonInput) { if (payLaterButtonInput) {