( PaymentMethodRegistry $payment_method_registry ) {
$payment_method_registry->register(
Package::container()->get( Cheque::class )
);
$payment_method_registry->register(
Package::container()->get( PayPal::class )
);
$payment_method_registry->register(
Package::container()->get( BankTransfer::class )
);
$payment_method_registry->register(
Package::container()->get( CashOnDelivery::class )
);
}
/**
* Verify all dependencies of registered payment methods have been registered.
* If not, remove that payment method script from the list of dependencies
* of Cart and Checkout block scripts so it doesn't break the blocks and show
* an error in the admin.
*/
public function verify_payment_methods_dependencies() {
// Check that the wc-blocks script is registered before continuing. Some extensions may cause this function to run
// before the payment method scripts' dependencies are registered.
if ( ! wp_script_is( 'wc-blocks', 'registered' ) ) {
return;
}
$wp_scripts = wp_scripts();
$payment_method_scripts = $this->payment_method_registry->get_all_active_payment_method_script_dependencies();
foreach ( $payment_method_scripts as $payment_method_script ) {
if (
! array_key_exists( $payment_method_script, $wp_scripts->registered ) ||
! property_exists( $wp_scripts->registered[ $payment_method_script ], 'deps' )
) {
continue;
}
$deps = $wp_scripts->registered[ $payment_method_script ]->deps;
foreach ( $deps as $dep ) {
if ( ! wp_script_is( $dep, 'registered' ) ) {
$error_handle = $dep . '-dependency-error';
$error_message = sprintf(
'Payment gateway with handle \'%1$s\' has been deactivated in Cart and Checkout blocks because its dependency \'%2$s\' is not registered. Read the docs about registering assets for payment methods: https://github.com/woocommerce/woocommerce-blocks/blob/060f63c04f0f34f645200b5d4da9212125c49177/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#registering-assets',
esc_html( $payment_method_script ),
esc_html( $dep )
);
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log( $error_message );
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter,WordPress.WP.EnqueuedResourceParameters.MissingVersion
wp_register_script( $error_handle, '' );
wp_enqueue_script( $error_handle );
wp_add_inline_script(
$error_handle,
sprintf( 'console.error( "%s" );', $error_message )
);
$cart_checkout_scripts = [ 'wc-cart-block', 'wc-cart-block-frontend', 'wc-checkout-block', 'wc-checkout-block-frontend' ];
foreach ( $cart_checkout_scripts as $script_handle ) {
if (
! array_key_exists( $script_handle, $wp_scripts->registered ) ||
! property_exists( $wp_scripts->registered[ $script_handle ], 'deps' )
) {
continue;
}
// Remove payment method script from dependencies.
$wp_scripts->registered[ $script_handle ]->deps = array_diff(
$wp_scripts->registered[ $script_handle ]->deps,
[ $payment_method_script ]
);
}
}
}
}
}
}
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Blocks\Payments\Api" not found in /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php:326
Stack trace:
#0 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\Blocks\Domain\Bootstrap->Automattic\WooCommerce\Blocks\Domain\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#1 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#2 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#3 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php(146): Automattic\WooCommerce\Blocks\Registry\Container->get('Automattic\\WooC...')
#4 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php(85): Automattic\WooCommerce\Blocks\Domain\Bootstrap->init()
#5 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Package.php(107): Automattic\WooCommerce\Blocks\Domain\Bootstrap->__construct(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#6 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\Blocks\Package::Automattic\WooCommerce\Blocks\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#7 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#8 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container))
#9 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Package.php(44): Automattic\WooCommerce\Blocks\Registry\Container->get('Automattic\\WooC...')
#10 [internal function]: Automattic\WooCommerce\Blocks\Package::init()
#11 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Packages.php(287): call_user_func(Array)
#12 /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Packages.php(85): Automattic\WooCommerce\Packages::initialize_packages()
#13 /htdocs/tapicarpro.com/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Packages::on_init('')
#14 /htdocs/tapicarpro.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#15 /htdocs/tapicarpro.com/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#16 /htdocs/tapicarpro.com/wp-settings.php(578): do_action('plugins_loaded')
#17 /htdocs/tapicarpro.com/wp-config.php(98): require_once('/htdocs/tapicar...')
#18 /htdocs/tapicarpro.com/wp-load.php(50): require_once('/htdocs/tapicar...')
#19 /htdocs/tapicarpro.com/wp-blog-header.php(13): require_once('/htdocs/tapicar...')
#20 /htdocs/tapicarpro.com/index.php(17): require('/htdocs/tapicar...')
#21 {main}
thrown in /htdocs/tapicarpro.com/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php on line 326