From cdcadc72bc8c62b16c8df611e0bc8eb77886a588 Mon Sep 17 00:00:00 2001 From: amirinterlutions Date: Thu, 22 Jun 2023 15:24:30 +0200 Subject: [PATCH] [PAYONE-190] if the customer has a company address, the birthday is not required --- .../PayonePayolutionInvoicingPaymentHandler.php | 6 +++++- .../storefront/payone/payolution/consent-checkbox.html.twig | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php b/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php index 021bdadc7..084b5b7c0 100644 --- a/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php +++ b/src/PaymentHandler/PayonePayolutionInvoicingPaymentHandler.php @@ -18,7 +18,11 @@ public function getValidationDefinitions(SalesChannelContext $salesChannelContex $definitions = parent::getValidationDefinitions($salesChannelContext); $definitions['payolutionConsent'] = [new NotBlank()]; - $definitions['payolutionBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + + // if the customer has a company address, the birthday is not required + if ($salesChannelContext->getCustomer()?->getDefaultBillingAddress()?->getCompany() === null) { + $definitions['payolutionBirthday'] = [new NotBlank(), new Birthday(['value' => $this->getMinimumDate()])]; + } $configuration = $this->configReader->read($salesChannelContext->getSalesChannel()->getId()); diff --git a/src/Resources/views/storefront/payone/payolution/consent-checkbox.html.twig b/src/Resources/views/storefront/payone/payolution/consent-checkbox.html.twig index 0d797f59c..6024f32db 100644 --- a/src/Resources/views/storefront/payone/payolution/consent-checkbox.html.twig +++ b/src/Resources/views/storefront/payone/payolution/consent-checkbox.html.twig @@ -1,4 +1,6 @@ {% block payone_payolution_consent_checkbox %} + + {% if context.customer.activeBillingAddress and context.customer.activeBillingAddress.company is empty %} + {% endif %}