Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Error notice triggered when using Elementor editor #7907

Closed
paymentplugins opened this issue Dec 9, 2022 · 5 comments · Fixed by #8428
Closed

Error notice triggered when using Elementor editor #7907

paymentplugins opened this issue Dec 9, 2022 · 5 comments · Fixed by #8428
Labels
block: checkout Issues related to the checkout block. type: bug The issue/PR concerns a confirmed bug. type: cooldown Things that are queued for a cooldown period (assists with planning). type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.

Comments

@paymentplugins
Copy link

Describe the bug

When using the Elementor post editor, the woocommerce-blocks/src/Payments/Api.php error_log message "Payment gateway with handle '%1$s' has been deactivated in Cart and Checkout blocks because its dependency '%2$s' is not registered." is triggered.

To reproduce

Steps to reproduce the behavior:

  1. Install WooCommerce 7.1+ and Elementor 3.9.0
  2. Navigate to the WordPress Admin > Posts > Add New
  3. On the post page, click the "Edit With Elementor" button. This will trigger the error_log entry.

Expected behavior

Editing a post using Elementor should not result in the script handles related to payments from being dequeued.

Environment

WordPress (please complete the following information):

  • WordPress version: 6.1.1
  • Gutenberg version (if installed): [e.g. 12.0.0]
  • WooCommerce version: 7.1.1
  • WooCommerce Blocks version: 8.7.6
  • Site language: English
  • Any other plugins installed: Elementor 3.9.0

Additional context

This error seems to occur because Elementor is not firing the init action when the Elementor post editor is opened. In woocommerce-blocks/src/AssetsController.php the register_assets method is associated with the init action. That is where all blocks scripts are registered.

In woocommerce-blocks/src/Payments/Api.php, there is the following line of code: add_action( 'wp_print_scripts', array( $this, 'verify_payment_methods_dependencies' ), 1 );. When the wp_print_scripts function action is triggered, WooCommerce Blocks validates that all dependencies for a given payment method script handle are registered.

However, if the init action is never fired, then none of the WooCommerce Blocks dependencies like wc-price-format etc are registered which results in that error message.

There should be some conditional check that ensures the verify_payment_methods_dependencies only executes if the init action has been run.

Example:

public function verify_payment_methods_dependencies() {
    if(!did_action('init')){
        return;
    }
}
@preadored
Copy link

Same on our site. Should I add a separate report with our site details?

@csmcneill
Copy link

35170274-hc

@gviger
Copy link

gviger commented Jan 9, 2023

Same on our site. Shows on default new empty Woo Shop page even with Stripe plugin disabled. All plugins, Wordpress etc at most recent versions. Just showed up today after WooCommerce 7.2.2 auto update yesterday.

@mikejolley
Copy link
Member

The suggested solution to check if init ran looks good to me. I will move this to the backlog so someone can work on it.

@mikejolley mikejolley added type: cooldown Things that are queued for a cooldown period (assists with planning). type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. labels Jan 30, 2023
@rossviviano
Copy link

40442355-hc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: checkout Issues related to the checkout block. type: bug The issue/PR concerns a confirmed bug. type: cooldown Things that are queued for a cooldown period (assists with planning). type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.
Projects
None yet
6 participants