Skip to content

Commit

Permalink
Merge pull request #515 from pagarme/fix-checkoutblocks-address
Browse files Browse the repository at this point in the history
fix: validate if checkoutblocks active
  • Loading branch information
fabiano-mallmann authored Nov 13, 2024
2 parents 7aeaab0 + ce0033f commit 0a42e93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Action/CustomerFieldsActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ public function addDocumentField(array $fields): array
public function addDocumentFieldOnCheckoutBlocks()
{
if (
$this->customerFields->hasCheckoutBlocksDocumentField()
|| !function_exists('woocommerce_register_additional_checkout_field')
Utils::isCheckoutBlocksActive() &&
($this->customerFields->hasCheckoutBlocksDocumentField()
|| !function_exists('woocommerce_register_additional_checkout_field'))
) {
return;
}
Expand Down
11 changes: 11 additions & 0 deletions src/Helper/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,15 @@ public static function getRegisterScriptParameters(string $path, string $fileNam
'ver' => self::getScriptVersion($path, $fileName)
];
}

/**
* @return bool
*/
public static function isCheckoutBlocksActive()
{
if (!class_exists('\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils')) {
return false;
}
return \Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils::is_checkout_block_default();
}
}

0 comments on commit 0a42e93

Please sign in to comment.