Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - -
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

Tagged: 

This topic contains 4 replies, has 0 voices.

Last updated by Christopher Amirian 1 month ago.

Assisted by: Christopher Amirian.

Author Posts
July 3, 2026 at 6:22 pm #18140553

Garrett McGilvray

Hi,

I would like to report deprecation notices in PHP 8.3 that I have traced to your WpmlSavePostHooks::on_product_save() method. The background is that I am trying to maintain a third-party plugin that deals with WooCommerce inventory management. It makes AJAX calls to update various inventory things. For example, to update manage stock status, it follows the WC approved method:

    $product = wc_get_product( $id );
    $product->set_manage_stock( $manage );
    $product->save();

But now with PHP 8.3, we are getting deprecation notices:

[03-Jul-2026 16:22:03 UTC] PHP Deprecated:  Creation of dynamic property WC_Product_Simple::$ID is deprecated in […]/wp-includes/post.php on line 2934
[03-Jul-2026 16:22:03 UTC] PHP Deprecated:  Creation of dynamic property WC_Product_Simple::$filter is deprecated in […]/wp-includes/post.php on line 2939

This seems to happen because, when we save the product, the woocommerce_after_product_object_save hook fires, into which WPML hooks its WpmlSavePostHooks::on_product_save( $post ) method (in plugins/sitepress-multilingual-cms/classes/hooks/WpmlSavePostHooks.php). The woocommerce_after_product_object_save is fired with WC_Product object as the first argument, which the on_product_save() method tries to immediately pass into get_post().

There is the problem, because get_post() is expecting either a post ID as an integer or a WP_Post object. Instead it gets a WC_Product object, which it tries to fix with sanitize_post(). A WC_Product object does not have a public $ID property, so sanitize_post() tries to set one in the old deprecated way.

Adding the following to the top of on_product_save() seems to resolve the issue in my testing, but I won't presume to understand the inner workings of your rather complex plugin. But in case it is helpful:

if ( $post instanceof \WC_Product ) {
	$post = $post->get_id();
}

Thank you for looking into this. I am not expecting an immediate fix: it's just a deprecation notice on dev copies of the site, so we can overlook it for now and move on.

WordPress 6.9.4
PHP 8.3
WPML Multilingual CMS 4.9.5
WPML Multilingual & Multicurrency for WooCommerce 5.5.6

July 5, 2026 at 10:33 am #18141795

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you for the details. I wonder how we can replicate this on a clean installation?

I created a WPML, WordPress, and WooCommerce site that you can check here:

hidden link

You can use the functions.php of the theme to add the function you try to use to show the deprecation error.

Thanks.

July 6, 2026 at 9:48 pm #18144049

Garrett McGilvray

Hi, Christopher,

Thank you for setting up that test site. I have logged into it, created a test WooCommerce product, and added some basic code to the bottom of the theme function file. The key parts of the test are that it passes through AJAX as our function would, and then it sets the Manage Stock value of a product using the same basic logic, so hopefully you can see the notices as I do.

1. Log in to the website as admin.
2. Visit: hidden link

You should see the following:

-------

✅ Manage stock has been set to true for product Test Product (ID: 19).

Please check your PHP error log / debug.log for the deprecation notice(s).

-------

Supposing error logging is set appropriately for this test site, there should already be a couple entries of the deprecation notices from my test of the code on your site. You should be able to refresh the URL above to test as many times as you need.

July 7, 2026 at 2:29 pm #18145639

Christopher Amirian
Supporter

Hello and thank you. I reported this to the second-tier support.

Thanks.

July 10, 2026 at 7:34 am #18151003

Christopher Amirian
Supporter

Hello, and thank you for reporting this issue. The deprecation notice problem is assessed by our second tier support and considered as a bug and the issue is now escalated to our development team.

There is no ETA for a fix, and for now you can use the workaround you already suggested.

Thanks.