diff --git a/modules/ppcp-blocks/src/BlocksModule.php b/modules/ppcp-blocks/src/BlocksModule.php
index eb1ccc01b..2c38f9b5a 100644
--- a/modules/ppcp-blocks/src/BlocksModule.php
+++ b/modules/ppcp-blocks/src/BlocksModule.php
@@ -34,29 +34,49 @@ class BlocksModule implements ModuleInterface {
* {@inheritDoc}
*/
public function run( ContainerInterface $c ): void {
- if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
+ if (
+ ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' )
+ || ! function_exists( 'woocommerce_store_api_register_payment_requirements' )
+ ) {
add_action(
- 'woocommerce_blocks_payment_method_type_registration',
- function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
- $payment_method_registry->register( $c->get( 'blocks.method' ) );
+ 'admin_notices',
+ function () {
+ printf(
+ '
',
+ wp_kses_post(
+ __(
+ 'PayPal checkout block initialization failed, possibly old WooCommerce version or disabled WooCommerce Blocks plugin.',
+ 'woocommerce-paypal-payments'
+ )
+ )
+ );
}
);
- woocommerce_store_api_register_payment_requirements(
- array(
- 'data_callback' => function() use ( $c ): array {
- $smart_button = $c->get( 'button.smart-button' );
- assert( $smart_button instanceof SmartButton );
-
- if ( isset( $smart_button->script_data()['continuation'] ) ) {
- return array( 'ppcp_continuation' );
- }
-
- return array();
- },
- )
- );
+ return;
}
+
+ add_action(
+ 'woocommerce_blocks_payment_method_type_registration',
+ function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
+ $payment_method_registry->register( $c->get( 'blocks.method' ) );
+ }
+ );
+
+ woocommerce_store_api_register_payment_requirements(
+ array(
+ 'data_callback' => function() use ( $c ): array {
+ $smart_button = $c->get( 'button.smart-button' );
+ assert( $smart_button instanceof SmartButton );
+
+ if ( isset( $smart_button->script_data()['continuation'] ) ) {
+ return array( 'ppcp_continuation' );
+ }
+
+ return array();
+ },
+ )
+ );
}
/**