mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Add filter allowing to disable the basic client-side validation
In case some conflicts occur.
This commit is contained in:
parent
2215bed31e
commit
be9c624264
3 changed files with 82 additions and 60 deletions
|
@ -31,6 +31,7 @@ const bootstrap = () => {
|
||||||
const onSmartButtonClick = (data, actions) => {
|
const onSmartButtonClick = (data, actions) => {
|
||||||
window.ppcpFundingSource = data.fundingSource;
|
window.ppcpFundingSource = data.fundingSource;
|
||||||
|
|
||||||
|
if (PayPalCommerceGateway.basic_checkout_validation_enabled) {
|
||||||
// TODO: quick fix to get the error about empty form before attempting PayPal order
|
// TODO: quick fix to get the error about empty form before attempting PayPal order
|
||||||
// it should solve #513 for most of the users, but proper solution should be implemented later.
|
// it should solve #513 for most of the users, but proper solution should be implemented later.
|
||||||
const requiredFields = jQuery('form.woocommerce-checkout .validate-required:visible :input');
|
const requiredFields = jQuery('form.woocommerce-checkout .validate-required:visible :input');
|
||||||
|
@ -43,6 +44,7 @@ const bootstrap = () => {
|
||||||
|
|
||||||
return actions.reject();
|
return actions.reject();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const form = document.querySelector('form.woocommerce-checkout');
|
const form = document.querySelector('form.woocommerce-checkout');
|
||||||
if (form) {
|
if (form) {
|
||||||
|
|
|
@ -88,6 +88,7 @@ return array(
|
||||||
$settings_status,
|
$settings_status,
|
||||||
$currency,
|
$currency,
|
||||||
$container->get( 'wcgateway.all-funding-sources' ),
|
$container->get( 'wcgateway.all-funding-sources' ),
|
||||||
|
$container->get( 'button.basic-checkout-validation-enabled' ),
|
||||||
$container->get( 'woocommerce.logger.woocommerce' )
|
$container->get( 'woocommerce.logger.woocommerce' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -201,4 +202,12 @@ return array(
|
||||||
return ! $container->get( 'button.is-logged-in' ) &&
|
return ! $container->get( 'button.is-logged-in' ) &&
|
||||||
$container->get( 'button.registration-required' );
|
$container->get( 'button.registration-required' );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'button.basic-checkout-validation-enabled' => static function ( ContainerInterface $container ): bool {
|
||||||
|
/**
|
||||||
|
* The filter allowing to disable the basic client-side validation of the checkout form
|
||||||
|
* when the PayPal button is clicked.
|
||||||
|
*/
|
||||||
|
return (bool) apply_filters( 'woocommerce_paypal_payments_basic_checkout_validation_enabled', true );
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -144,6 +144,13 @@ class SmartButton implements SmartButtonInterface {
|
||||||
*/
|
*/
|
||||||
private $all_funding_sources;
|
private $all_funding_sources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the basic JS validation of the form iss enabled.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $basic_checkout_validation_enabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger.
|
* The logger.
|
||||||
*
|
*
|
||||||
|
@ -176,6 +183,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
* @param SettingsStatus $settings_status The Settings status helper.
|
* @param SettingsStatus $settings_status The Settings status helper.
|
||||||
* @param string $currency 3-letter currency code of the shop.
|
* @param string $currency 3-letter currency code of the shop.
|
||||||
* @param array $all_funding_sources All existing funding sources.
|
* @param array $all_funding_sources All existing funding sources.
|
||||||
|
* @param bool $basic_checkout_validation_enabled Whether the basic JS validation of the form iss enabled.
|
||||||
* @param LoggerInterface $logger The logger.
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -194,6 +202,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
SettingsStatus $settings_status,
|
SettingsStatus $settings_status,
|
||||||
string $currency,
|
string $currency,
|
||||||
array $all_funding_sources,
|
array $all_funding_sources,
|
||||||
|
bool $basic_checkout_validation_enabled,
|
||||||
LoggerInterface $logger
|
LoggerInterface $logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -212,6 +221,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
$this->settings_status = $settings_status;
|
$this->settings_status = $settings_status;
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
$this->all_funding_sources = $all_funding_sources;
|
$this->all_funding_sources = $all_funding_sources;
|
||||||
|
$this->basic_checkout_validation_enabled = $basic_checkout_validation_enabled;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,6 +866,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
'order_id' => 'pay-now' === $this->context() ? absint( $wp->query_vars['order-pay'] ) : 0,
|
'order_id' => 'pay-now' === $this->context() ? absint( $wp->query_vars['order-pay'] ) : 0,
|
||||||
'single_product_buttons_enabled' => $this->settings->has( 'button_product_enabled' ) && $this->settings->get( 'button_product_enabled' ),
|
'single_product_buttons_enabled' => $this->settings->has( 'button_product_enabled' ) && $this->settings->get( 'button_product_enabled' ),
|
||||||
'mini_cart_buttons_enabled' => $this->settings->has( 'button_mini-cart_enabled' ) && $this->settings->get( 'button_mini-cart_enabled' ),
|
'mini_cart_buttons_enabled' => $this->settings->has( 'button_mini-cart_enabled' ) && $this->settings->get( 'button_mini-cart_enabled' ),
|
||||||
|
'basic_checkout_validation_enabled' => $this->basic_checkout_validation_enabled,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $this->style_for_context( 'layout', 'mini-cart' ) !== 'horizontal' ) {
|
if ( $this->style_for_context( 'layout', 'mini-cart' ) !== 'horizontal' ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue