qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
553 stars 104 forks source link

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

Closed yoancutillas closed 2 years ago

yoancutillas commented 2 years ago

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 commented 2 years ago

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

herrvigg commented 2 years ago

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

yoancutillas commented 2 years ago

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

herrvigg commented 2 years ago

Fix released in 3.12.1.