Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

The client was unable to translate the Single Product Layout using WPML as it would freeze and changes could not be saved. Other layouts were translating without issues.

Solution:

We identified that this issue was related to a known problem with the WoodMart theme, which has been documented here: WoodMart Fatal Error When Translating Product Layouts.

To resolve this, we recommended adding the following code to the functions.php file of the client's child theme and clearing the caches:

add_action( 'woocommerce_before_template_part', function () {
    global $product;
  
    if ( wp_is_json_request() && ! $product ) {
        $random_product = new WP_Query(
            array(
                'posts_per_page' => '1',
                'post_type'      => 'product',
            )
        );
  
        while ( $random_product->have_posts() ) {
            $random_product->the_post();
            $product_id = get_the_ID();
        }
  
        wp_reset_postdata();
  
        $product = wc_get_product( $product_id );
    }
} );

We advised the client to try translating the Product Layout again to ensure it works as expected.

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 WPML Known Issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If issues persist, please open a new support ticket.

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.

Tagged: 

This topic contains 5 replies, has 0 voices.

Last updated by Bigul 1 month, 1 week ago.

Assisted by: Bigul.

Author Posts
April 24, 2025 at 10:28 am #16963807

xavierC-5

Hi Bigul,

The Single Product Layout cannot be translated as it freezes all the time. No way to save it. The rest of the Layouts work fine.

Regards.

16941587-Image_015.jpg
April 24, 2025 at 1:20 pm #16964625

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

It looks like this bug is related to the following known issue.

https://wpml.org/errata/woodmart-fatal-error-when-translating-product-layouts/

I got the expected results on after adding the following code in functions.php of your child theme and clearing the caches.

add_action( 'woocommerce_before_template_part', function () {
    global $product;
 
    if ( wp_is_json_request() && ! $product ) {
        $random_product = new WP_Query(
            array(
                'posts_per_page' => '1',
                'post_type'      => 'product',
            )
        );
 
        while ( $random_product->have_posts() ) {
            $random_product->the_post();
            $product_id = get_the_ID();
        }
 
        wp_reset_postdata();
 
        $product = wc_get_product( $product_id );
    }
} );

Please try to translate the Product Layout now and make sure it is working as expected or not. Refer to the attached images for more details.

--
Thanks!

Bigul

2025-04-24_16h00_15.png
2025-04-24_15h59_35.png
April 29, 2025 at 11:23 am #16978589

xavierC-5

Hi Bigul,
Sorry for the delay but here in Vietnam we're on local holidays.
I'll check and revert to you asap.

Taking advantge that you are checking couple of problems, did you have time to check the media translation that is not working?

Thanks Bigul

April 29, 2025 at 2:47 pm #16979865

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. Take your time. We will wait for your feedback. I will update you shortly on the original ticket.

--
Thanks!

Bigul

May 5, 2025 at 9:04 am #16995311

xavierC-5

Hi Bigul,

I inform you that this issue has been resolved:
https://wpml.org/errata/woodmart-fatal-error-when-translating-product-layouts/

So let's please focus on the other 2 problems:
1/ Problem with the variation products showing a blank page. Main ticket. Any news on that?
2/ Media Translation is not working.

Thanks

May 5, 2025 at 1:39 pm #16996519

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates and confirmation. Please check my last reply on both tickets and share your feedback there. That would be very helpful.

--
Thanks!

Bigul