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

Calling $order->id triggers a PHP Notice: Function id was called incorrectly. Order properties should not be accessed directly. #1189

Closed
yoancutillas opened this issue Jun 13, 2022 · 4 comments
Labels
module: WC Integration with Woo Commerce

Comments

@yoancutillas
Copy link

This PHP notice appears when a WC email is sent.
E.g.: go to WooCommerce > Orders > open an order > Order actions = "Email invoice / order details to customer" > Send.

Replace qtranslate-xt\modules\woo-commerce\ qwc-admin.php line 356-358

if ( $order && isset( $order->id ) ) {
        $lang = get_post_meta( $order->id, '_user_language', true );
}

with

if ( $order && $order->get_id() ) {
        $lang = get_post_meta( $order->get_id(), '_user_language', true );
}

Replace qtranslate-xt\modules\woo-commerce\ qwc-admin.php line 375-379

if ( ! $order || ! isset( $order->id ) ) {
        return;
}

$lang = get_post_meta( $order->id, '_user_language', true );

with

if ( ! ( $order && $order->get_id() ) ) {
        return;
}

$lang = get_post_meta( $order->get_id(), '_user_language', true );
@herrvigg herrvigg added the module: WC Integration with Woo Commerce label Jun 13, 2022
herrvigg added a commit that referenced this issue Jun 14, 2022
The correct usage is `$order->get_id()`.
@herrvigg
Copy link
Collaborator

Thanks for reporting this, very clear description. Fixed in master.

herrvigg added a commit that referenced this issue Jun 14, 2022
The correct usage is `$order->get_id()`.
@herrvigg
Copy link
Collaborator

Was this simply triggering a notice or preventing the emails to be sent?

@yoancutillas
Copy link
Author

Just a PHP notice, but if WP_DEBUG is TRUE, the notice is displayed in the email.
php-notice-email

@herrvigg
Copy link
Collaborator

herrvigg commented Sep 4, 2022

Fix released in 3.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: WC Integration with Woo Commerce
Projects
None yet
Development

No branches or pull requests

2 participants