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

Compatibility Issue: woocommerce_before_thankyou Hook Passing Order Object Instead of Order ID #11851

Closed
nate-allen opened this issue Nov 20, 2023 · 0 comments · Fixed by #11862
Assignees
Labels
priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue/PR concerns a confirmed bug.

Comments

@nate-allen
Copy link

Describe the bug

The Order Confirmation Block passes an order object when it triggers the woocommerce_before_thankyou hook even though WooCommerce has always passed an order ID in the thankyou.php template, which is now leading to type conflicts.

To reproduce

Steps to reproduce the behavior:

  1. Implement a function that expects an integer for the order ID, attached to the woocommerce_before_thankyou hook. Example function:
function example_function( int $order_id ): void {
    // Function logic that expects $order_id to be an integer
}
add_action( 'woocommerce_before_thankyou', 'example_function' );
  1. Place an order on the WooCommerce store.
  2. Observe the behavior during the "Thank You" page load, which results in a type error due to the function expecting an integer but receiving an object instead.

Expected behavior

The expected behavior is for the woocommerce_before_thankyou hook to maintain backward compatibility by passing an order ID (integer).

Environment

WordPress (please complete the following information):

  • WordPress version: 6.4.1
  • WooCommerce version: 8.3.0
  • Site language: English
  • Any other plugins installed: Google Listings & Ads

Desktop (please complete the following information):

  • OS: macOS
  • Browser: chrome
  • Version: 119.0.6045.159

Additional context

We're running into this on a Team51 partner site. We noticed this issue when the Google Listings & Ads plugin threw a fatal after a recent WooCommerce update.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
3 participants