Skip to content

Commit

Permalink
fix: refactor document field validation and checkout blocks handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiano-mallmann committed Nov 19, 2024
1 parent e7b8b80 commit caaa8b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Action/CustomerFieldsActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function addDocumentField(array $fields): array
public function addDocumentFieldOnCheckoutBlocks()
{
if (
Utils::isCheckoutBlocksActive() == false &&
($this->customerFields->hasCheckoutBlocksDocumentField()
!Utils::isCheckoutBlocksActive()
&& ($this->customerFields->hasCheckoutBlocksDocumentField()
|| !function_exists('woocommerce_register_additional_checkout_field'))
) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getCustomerDocumentByOrder($wcOrder)
if (empty($document)) {
throw new \InvalidArgumentException(__("Please, enter a valid document number.", 'woo-pagarme-payments'), 1);
}
return $document;
return $document;
}

public function saveOnPlatform($customer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ private function getRequestMetaData($orderRequest)
$metadata->moduleVersion = $versionService->getModuleVersion();
$metadata->coreVersion = $versionService->getCoreVersion();
$metadata->platformVersion = $versionService->getPlatformVersion();
$metadata->checkoutBlocks = false;
if(class_exists("\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils")){
$metadata->checkoutBlocks = CartCheckoutUtils::is_checkout_block_default();
}
if($this->hasCreditCardInPayments($orderRequest->payments) && !empty(MPSetup::getInstallmentType())){
$metadata->checkoutBlocks = class_exists("\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils")
&& CartCheckoutUtils::is_checkout_block_default();

if ($this->hasCreditCardInPayments($orderRequest->payments) && !empty(MPSetup::getInstallmentType())) {
$metadata->interestType = MPSetup::getInstallmentType();
}
return $metadata;
Expand All @@ -185,7 +184,7 @@ private function getRequestMetaData($orderRequest)
private function hasCreditCardInPayments($payments)
{
foreach ($payments as $payment) {
if($payment->paymentMethod === TransactionType::CREDIT_CARD) {
if ($payment->paymentMethod === TransactionType::CREDIT_CARD) {
return true;
}
}
Expand Down

0 comments on commit caaa8b2

Please sign in to comment.