diff --git a/src/Action/CustomerFieldsActions.php b/src/Action/CustomerFieldsActions.php index 20be485f..e9ea00ae 100644 --- a/src/Action/CustomerFieldsActions.php +++ b/src/Action/CustomerFieldsActions.php @@ -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; } diff --git a/src/Helper/Utils.php b/src/Helper/Utils.php index 776103c0..c37c5c51 100644 --- a/src/Helper/Utils.php +++ b/src/Helper/Utils.php @@ -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(); + } }