Skip to content

Commit

Permalink
Add birth from meta to fields in pay page PIWOO-521
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Sep 12, 2024
1 parent 228260e commit f68b429
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
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,15 @@ 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 +38,7 @@ public function execute($gateway, $dataHelper)
}

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

Expand All @@ -46,15 +49,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

0 comments on commit f68b429

Please sign in to comment.