Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add birth from meta to fields in pay page PIWOO-521 #939

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public function execute($gateway, $dataHelper)
$showPhoneField = false;
$isPhoneRequired = get_option('mollie_wc_is_phone_required_flag');
$phoneValue = false;
$birthValue = false;

if (is_checkout_pay_page()) {
$showBirthdateField = true;
$showPhoneField = true;
$order = $this->getOrderIdOnPayForOrderPage();
$phoneValue = $order->get_billing_phone();
$birthValue = $order->get_meta('billing_birthdate');
}

if (is_checkout() && !is_checkout_pay_page() && !$isPhoneRequired) {
Expand All @@ -35,7 +37,7 @@ public function execute($gateway, $dataHelper)
}

if ($showBirthdateField) {
$this->dateOfBirth();
$this->dateOfBirth($birthValue);
}
}

Expand All @@ -46,15 +48,16 @@ protected function getOrderIdOnPayForOrderPage()
return wc_get_order($orderId);
}

protected function dateOfBirth()
protected function dateOfBirth($birthValue)
{
$birthValue = $birthValue ?: '';
?>
<p class="form-row form-row-wide" id="billing_birthdate_field">
<label for="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>" class=""><?php echo esc_html__('Birthdate', 'mollie-payments-for-woocommerce'); ?>
</label>
<span class="woocommerce-input-wrapper">
<input type="date" class="input-text " name="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>"
id="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>" value=""
id="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>" value="<?php echo esc_attr($birthValue); ?>"
autocomplete="birthdate"></span>
</p>
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public function execute($gateway, $dataHelper)
$showPhoneField = false;
$isPhoneRequired = get_option('mollie_wc_is_phone_required_flag');
$phoneValue = false;
$birthValue = false;

if (is_checkout_pay_page()) {
$showBirthdateField = true;
$showPhoneField = true;
$order = $this->getOrderIdOnPayForOrderPage();
$phoneValue = $order->get_billing_phone();
$birthValue = $order->get_meta('billing_birthdate');
}

if (is_checkout() && !is_checkout_pay_page() && !$isPhoneRequired) {
Expand All @@ -35,7 +37,7 @@ public function execute($gateway, $dataHelper)
}

if ($showBirthdateField) {
$this->dateOfBirth();
$this->dateOfBirth($birthValue);
}
}

Expand All @@ -46,15 +48,16 @@ protected function getOrderIdOnPayForOrderPage()
return wc_get_order($orderId);
}

protected function dateOfBirth()
protected function dateOfBirth($birthValue)
{
$birthValue = $birthValue ?: '';
?>
<p class="form-row form-row-wide" id="billing_birthdate_field">
<label for="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>" class=""><?php echo esc_html__('Birthdate', 'mollie-payments-for-woocommerce'); ?>
</label>
<span class="woocommerce-input-wrapper">
<input type="date" class="input-text " name="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>"
id="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>" value=""
id="<?php echo esc_attr(self::FIELD_BIRTHDATE); ?>" value="<?php echo esc_attr($birthValue); ?>"
autocomplete="birthdate"></span>
</p>
<?php
Expand Down
Loading