Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if this is WooCommerce product before processing #2680

Merged
merged 2 commits into from
Jan 3, 2024

Conversation

budzanowski
Copy link
Contributor

@budzanowski budzanowski commented Jan 3, 2024

Changes proposed in this Pull Request:

Closes #2672 .

Check if we are dealing with WooCommerce product before processing.

  • Do the changed files pass phpcs checks? Please remove phpcs:ignore comments in changed files and fix any issues, or delete if not practical.

Detailed test instructions:

I can't reproduce the 2672 so really hard to tell.

Changelog entry

Fix - Fatal Error on order screens

@github-actions github-actions bot added changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug. labels Jan 3, 2024
@@ -315,7 +315,7 @@ public function __construct( WC_Facebookcommerce $facebook_for_woocommerce ) {

add_action( 'add_meta_boxes', 'WooCommerce\Facebook\Admin\Product_Sync_Meta_Box::register', 10, 1 );

add_action( 'add_meta_boxes', [ $this, 'display_batch_api_completed' ], 10, 2 );
add_action( 'add_meta_boxes_product', [ $this, 'display_batch_api_completed' ], 10, 2 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use add_meta_boxes_{$post_type} hook instead of add_meta_boxes . The order page triggers add_meta_boxes with screen_id and order instead of $post_type and $post.

$fb_product_item_id = null;
$should_sync = true;
$no_sync_reason = '';
public function display_batch_api_completed( $post ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibndawood
Copy link
Contributor

There are two errors:

When accessing from the edit page:

Fatal error: Uncaught Error: Call to a member function is_type() on bool
in /srv/htdocs/wp-content/plugins/facebook-for-woocommerce/facebook-commerce.php on line 1643

When accessing from the edit order:

Fatal error: Uncaught Error: WC_Facebookcommerce_Integration::display_batch_api_completed(): Argument #2 ($post) must be of type WP_Post, Automattic\WooCommerce\Admin\Overrides\Order given, called in /wordpress/core/6.4.2/wp-includes/class-wp-hook.php on line 324
in /srv/htdocs/wp-content/plugins/facebook-for-woocommerce/facebook-commerce.php on line 1628

I've pushed additional commit to fix the error triggered from edit order as well.

@ibndawood ibndawood merged commit 570cd2e into develop Jan 3, 2024
6 checks passed
@ibndawood ibndawood deleted the fix/fatal-2672 branch January 3, 2024 12:27
@rahulraina7
Copy link
Contributor

Thanks folks, couldn't have seen this one coming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants