Skip Navigation

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.

Our next available supporter will start replying to tickets in about 5.39 hours from now. Thank you for your understanding.

This topic contains 6 replies, has 2 voices.

Last updated by Long Nguyen 2 weeks ago.

Assisted by: Long Nguyen.

Author Posts
September 18, 2024 at 8:39 am #16191696

David Henry

Background of the issue:
I am trying to order a product with only 1 in stock on my site hidden link.

Symptoms:
The customer sees an error and it looks like two orders have been created, but only one order has gone through in the admin.

Questions:
Is there any documentation that covers this issue?

September 18, 2024 at 9:43 am #16191974

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

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.

Looking forward to your reply.
Thanks

September 19, 2024 at 5:18 pm #16200402

David Henry

Hi There,

I've disabled all plugins and themes and have found that there are still two issues.

1. "There was an error processing your payment..."
hidden link
This issue only happens when WPML String Translation is enabled.

2. The refund process doesn't work properly, see: hidden link
This only happens with WPML Multilingual CMS is active

To me is sounds like there are issues with the translations, most likely due to an odd character that can happen with the Irish language.

How do I investigate which language string is the problem?

I'm happy to remove all admin translations, I don't think they should be there anyway, I've inherited these.

Can you take a look?

[supporter removed]

David

September 20, 2024 at 2:08 am #16201026

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi David,

I found the issue. There is an error in the debug log when processing the checkout

[20-Sep-2024 01:53:24 UTC] PHP Fatal error:  Uncaught ValueError: Unknown format specifier "a" in /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-emails.php:735
Stack trace:
#0 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-emails.php(735): sprintf()
#1 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce-multilingual/inc/class-wcml-emails.php(857): WC_Emails->no_stock()
#2 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce-multilingual/inc/class-wcml-emails.php(833): WCML_Emails->admin_notification()
#3 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(324): WCML_Emails->no_stock_admin_notification()
#4 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#5 /usr/www/users/siopalea/stage/wp-includes/plugin.php(565): WP_Hook->do_action()
#6 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-emails.php(172): do_action_ref_array()
#7 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(324): WC_Emails::send_transactional_email()
#8 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#9 /usr/www/users/siopalea/stage/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/wc-stock-functions.php(259): do_action()
#11 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/wc-stock-functions.php(228): wc_trigger_stock_change_notifications()
#12 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/wc-stock-functions.php(117): wc_reduce_stock_levels()
#13 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(326): wc_maybe_reduce_stock_levels()
#14 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#15 /usr/www/users/siopalea/stage/wp-includes/plugin.php(517): WP_Hook->do_action()
#16 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-order.php(411): do_action()
#17 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-order.php(253): WC_Order->status_transition()
#18 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-order.php(365): WC_Order->save()
#19 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/gateways/cheque/class-wc-gateway-cheque.php(136): WC_Order->update_status()
#20 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1062): WC_Gateway_Cheque->process_payment()
#21 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1293): WC_Checkout->process_order_payment()
#22 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(520): WC_Checkout->process_checkout()
#23 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(324): WC_AJAX::checkout()
#24 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#25 /usr/www/users/siopalea/stage/wp-includes/plugin.php(517): WP_Hook->do_action()
#26 /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(96): do_action()
#27 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(324): WC_AJAX::do_wc_ajax()
#28 /usr/www/users/siopalea/stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#29 /usr/www/users/siopalea/stage/wp-includes/plugin.php(517): WP_Hook->do_action()
#30 /usr/www/users/siopalea/stage/wp-includes/template-loader.php(13): do_action()
#31 /usr/www/users/siopalea/stage/wp-blog-header.php(19): require_once('/usr/www/users/...')
#32 /usr/www/users/siopalea/stage/index.php(17): require('/usr/www/users/...')
#33 {main}
  thrown in /usr/www/users/siopalea/stage/wp-content/plugins/woocommerce/includes/class-wc-emails.php on line 735

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.

Refer documentation https://wpml.org/errata/php-8-php-fatal-error-uncaught-valueerror-unknown-format-specifier-in/

Looking forward to your reply.
Thanks

String Translation ‹ An Siopa Leabhar — WordPress 2024-09-20 08-58-37.png
September 20, 2024 at 8:53 am #16201704

David Henry

Thanks, I can see it's missing the "s". I'll now try the same method to resolve the refund issue.

September 20, 2024 at 9:47 am #16202196

David Henry

I've also fixed the refund problem that again, had a missing s.
Thanks for your help.
d

September 20, 2024 at 10:19 am #16202361

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Feel free to contact us again if you have any questions.

Thanks.

David Henry confirmed that the issue was resolved on 2024-09-20 11:47:01.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.