Skip to content

Commit

Permalink
Merge pull request #517 from pagarme/fix-bugs-address-and-checkoutblocks
Browse files Browse the repository at this point in the history
fix: bugs address and checkoutblocks
  • Loading branch information
fabiano-mallmann authored Nov 19, 2024
2 parents e11d22e + caaa8b2 commit 016ca1c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 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() &&
($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,8 +172,10 @@ private function getRequestMetaData($orderRequest)
$metadata->moduleVersion = $versionService->getModuleVersion();
$metadata->coreVersion = $versionService->getCoreVersion();
$metadata->platformVersion = $versionService->getPlatformVersion();
$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 @@ -182,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
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ public function setNumber($number)

$this->number = substr($numberWithoutLineBreaks, 0, 15);

if (empty(trim($this->number))) {
$inputName = $this->i18n->getDashboard('number');
$message = $this->i18n->getDashboard(
"The %s should not be empty!",
$inputName
);

throw new \Exception($message, 400);
}

return $this;
}

Expand Down

0 comments on commit 016ca1c

Please sign in to comment.