Skip to content

Commit

Permalink
Fix birthdate in classic PIWOO-521
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Sep 26, 2024
1 parent 9790352 commit bf8484c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Payment/MollieOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,11 +1005,15 @@ protected function getCustomerBirthdate($order)
$additionalFields = $gateway->paymentMethod()->getProperty('additionalFields');
$methodId = $additionalFields && in_array('birthdate', $additionalFields, true);
if ($methodId) {
$optionName = 'billing_birthdate_' . $gateway->paymentMethod()->getProperty('id');
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$fieldPosted = wc_clean(wp_unslash($_POST["billing_birthdate"] ?? ''));
$fieldPosted = wc_clean(wp_unslash($_POST[$optionName] ?? ''));
if ($fieldPosted === '' || !is_string($fieldPosted)) {
return null;
}

$order->update_meta_data($optionName, $fieldPosted);
$order->save();
$format = "Y-m-d";
return gmdate($format, (int) strtotime($fieldPosted));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class In3FieldsStrategy implements PaymentFieldsStrategyI
{
use PaymentFieldsStrategiesTrait;

const FIELD_BIRTHDATE = "billing_birthdate";
const FIELD_BIRTHDATE = "billing_birthdate_in3";
const FIELD_PHONE = "billing_phone_in3";

public function execute($gateway, $dataHelper)
Expand All @@ -24,7 +24,7 @@ public function execute($gateway, $dataHelper)
$showPhoneField = true;
$order = $this->getOrderIdOnPayForOrderPage();
$phoneValue = $order->get_billing_phone();
$birthValue = $order->get_meta('billing_birthdate');
$birthValue = $order->get_meta(self::FIELD_BIRTHDATE);
}

if (is_checkout() && !is_checkout_pay_page() && !$isPhoneRequired) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RivertyFieldsStrategy implements PaymentFieldsStrategyI
{
use PaymentFieldsStrategiesTrait;

const FIELD_BIRTHDATE = "billing_birthdate";
const FIELD_BIRTHDATE = "billing_birthdate_riverty";
const FIELD_PHONE = "billing_phone_riverty";

public function execute($gateway, $dataHelper)
Expand All @@ -24,7 +24,7 @@ public function execute($gateway, $dataHelper)
$showPhoneField = true;
$order = $this->getOrderIdOnPayForOrderPage();
$phoneValue = $order->get_billing_phone();
$birthValue = $order->get_meta('billing_birthdate');
$birthValue = $order->get_meta(self::FIELD_BIRTHDATE);
}

if (is_checkout() && !is_checkout_pay_page() && !$isPhoneRequired) {
Expand Down

0 comments on commit bf8484c

Please sign in to comment.