Skip to content

Commit

Permalink
Phone not required in checkout with in3
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed May 18, 2024
1 parent 57f6253 commit c5651d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
3 changes: 1 addition & 2 deletions resources/js/blocks/molliePaymentMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,11 @@ const MollieComponent = (props) => {
phoneLabel.innerText = phoneString
}
}
let isPhoneEmpty = (billing.billingData.phone === '' && shippingData.shippingAddress.phone === '') && inputPhone === '';
let isBirthdateEmpty = inputBirthdate === ''
const unsubscribeProcessing = onCheckoutValidation(

() => {
if (activePaymentMethod === 'mollie_wc_gateway_in3' && (isPhoneEmpty || isBirthdateEmpty)) {
if (activePaymentMethod === 'mollie_wc_gateway_in3' && isBirthdateEmpty) {
return {
errorMessage: item.errorMessage,
};
Expand Down
27 changes: 3 additions & 24 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,17 +687,7 @@ public function in3FieldsMandatoryPayForOrder($order)
}
$phoneValue = filter_input(INPUT_POST, 'billing_phone_in3', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
$phoneValid = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : null;
$phoneLabel = __('Phone', 'mollie-payments-for-woocommerce');

if (!$phoneValue) {
wc_add_notice(
sprintf(
__('%s is a required field. Valid phone format +316xxxxxxxx', 'mollie-payments-for-woocommerce'),
"<strong>$phoneLabel</strong>"
),
'error'
);
}
if ($phoneValid) {
$order->set_billing_phone($phoneValue);
}
Expand Down Expand Up @@ -782,23 +772,12 @@ public function addPaymentMethodMandatoryFieldsPhoneVerification(
return $fields;
}
$fieldPosted = filter_input(INPUT_POST, $field, FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
if (!$fieldPosted) {
$errors->add(
'validation',
sprintf(
__('%s is a required field. Valid phone format +316xxxxxxxx', 'woocommerce'),
"<strong>$fieldLabel</strong>"
)
);
return $fields;
}

if (!$this->isPhoneValid($fieldPosted)) {
$fields['billing_phone'] = null;
return $fields;
} else {
if ($fieldPosted && !$this->isPhoneValid($fieldPosted)) {
$fields['billing_phone'] = $fieldPosted;
return $fields;
}
$fields['billing_phone'] = null;
return $fields;
}

Expand Down

0 comments on commit c5651d1

Please sign in to comment.