Resolved
Resolved in: 4.12.0
Overview of the issue
After translating a product, sometimes product variations in the default language are no longer visible on the front-end.
The reason for this is that the transient of the variation is stored in the translated language code instead of the default language code. WooCommerce Variable product children transient can be sometimes populated with wrong values if it’s computed on-page in a different language.
Unfortunately, we could not identify in which context this is happening.
Workaround
Until we have better information of the context, we suggest adding the following snippet to your theme’s functions.php file:
/** * Prevent issues with product variations transient when it's * computed in a secondary language page for a product in * the default language. * * @link https://onthegosystems.myjetbrains.com/youtrack/issue/wcml-3671 */ add_filter( 'woocommerce_variable_children_args', function( $args ) { global $sitepress; $parseQueryAction = [ $sitepress, 'parse_query' ]; if ( remove_action( 'parse_query', $parseQueryAction ) ) { add_action( 'setted_transient', function() use ( $parseQueryAction ) { add_action( 'parse_query', $parseQueryAction ); } ); } return $args; } );
Hi,
we have this issue for a while now.
It is very hard to pin down and it seems to happen when an order is placed.
It does not happen everytime but it seems to be more likely to happen when the stock is going from > 0 to < 0.
Best
Sven
Thank you very much for reporting this, Sven. It is a strange edge case and it worth to check it carefully in our support forum. Could you please open a ticker for it?
https://wpml.org/forums/forum/english-support/
Thank you Sven for this precious information. We’ll try this scenario soon.
Meanwhile, we suggest to use the temporary snippet to prevent the issue.
Hi,
After ordering in French or in English, there is a problem with some products that in languages other than the default language, product variations are no longer selectable in WooCommerce. Unfortunately, I can’t reproduce the error 100%, because it doesn’t occur with every order in French. But mostly after French orders have arrived.
Is it a known problem that product variants are no longer selectable after orders in certain languages? By the way, simply saving the product again solves the problem immediately.
There is probably a connection to the case in this ticket.
Nevertheless, I have tried the workaround shown here and my described problem has been solved.
Now I’m wondering whether this code could represent a security vulnerability in any way, whether you have already found another solution or whether I can keep this workaround without a guilty conscience.
Regards,
Stefan
Hi Stefan,
Thanks for confirming the fix.
The workaround does not represent any security vulnerability.
We already prepared a more robust fix for this issue, but it requires changes both in WCML and WPML. The WPML part has been included in WPML 4.4.12. The second part will come in WCML 4.12.0 (which should go out in the coming weeks).
Once WCML 4.12.0 is release, you will be able to remove this temporary snippet.
Thanks,
Pierre
Hey everyone,
We just released WCML 4.12.0 which should solve this issue. Don’t hesitate to make a full backup before proceeding.
Regards