This thread is resolved. Here is a description of the problem and solution.
Problem: The client was experiencing an issue where attempting to order a product with only 1 in stock resulted in an error, and it appeared as though two orders were created, but only one was processed in the admin. This occurred when WPML String Translation was enabled, and there was also a problem with the refund process when WPML Multilingual CMS was active. Solution: We identified a PHP fatal error related to a format specifier in the WooCommerce email notification system. The error was traced to a translation string for the 'out of stock' message in WPML String Translation, which had an incorrect format. We corrected the translation from "Níl stoc de % againn." to "Níl stoc de %s againn." and verified that the checkout and refund processes functioned correctly thereafter. For further details on this type of error, you can refer to the documentation at https://wpml.org/errata/php-8-php-fatal-error-uncaught-valueerror-unknown-format-specifier-in/.
If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket at WPML support forum.
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.
Here is the forum ticket. I observed that after completing the order, the product stock was not synced correctly in the admin area. It could be affected by another plugin or code on the site.
I suggest you copy your site to a staging site then make some tests:
1. Enable a minimal environment:
- Deactivate all plugins except WPML plugins and WooCommerce.
- Switch to a standard theme of WordPress.
2. Deactivate only WPML and keep other plugins activated.
the code in the file wp-content/plugins/woocommerce/includes/class-wc-emails.php line 735 is
$message = sprintf( __( '%s is out of stock.', 'woocommerce' ), html_entity_decode( wp_strip_all_tags( $product->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
then I search for the string "%s is out of stock" in WPML > String Translation and see that the translation string doesn't have the correct format for the placeholder "Níl stoc de % againn.", see the attached screenshot.
I correct the translation to "Níl stoc de %s againn." and save it. Now I can complete the checkout process and refund the order as well.