Skip Navigation

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

Problem:
I want to translate the SKU number value in the Advanced Translation Editor.
Solution:
By default, the Advanced Translation Editor does not include the numeric value. If you want to translate this value, please add the code below to the file functions.php in the theme folder.

function wpmlsupp_7499_allow_translating_numbers( $is_translatable, $job_translate ) {
    $data = $job_translate['field_data'];
    if ( 'base64' === $job_translate['field_format'] ) {
        $data = base64_decode( $data );
    }
    if ( is_numeric( $data ) ) {
        return true;
    }
    return $is_translatable;
}
add_filter( 'wpml_tm_job_field_is_translatable', 'wpmlsupp_7499_allow_translating_numbers', 10, 2 );

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.

This topic contains 5 replies, has 2 voices.

Last updated by yuryE 1 year, 4 months ago.

Assisted by: Long Nguyen.

Author Posts
December 15, 2023 at 6:10 pm #15075715

yuryE

Hallo!
When translating a variable product, the SKU (on my website SKU rename to REF) number is displayed from the PARENT product but not from the VARIABLE product as in the original language.

I can provide all accesses so that you can familiarize yourself with the situation.

ORIGINAL
hidden link

OTHER LANGUAGE
hidden link

By clicking on one of the Product options you will see below after the Product Description there is REF.

ORIGINAL
Compact powder – mikronizēts kompaktais pūderis (10gr.)
Natural beige 70505
REF: 70505

OTHER LANGUAGE
Compact powder – micronized compact powder (10gr.)
Natural beige 70505
SKU: 705xx

When a product is opened without the selected option, there is a REF at the bottom. And when translated, this REF is placed in variable products...

I would be grateful for any help.

December 15, 2023 at 10:46 pm #15076209

yuryE

I found this option on your website:

<wpml-config>
<custom-fields>
<custom-field action="copy">sku</custom-field>
<custom-field action="copy">ref</custom-field>
</custom-fields>
</wpml-config>

This is a link to the test product, it shows that now when switching to another language there is a replacement for REF
hidden link

the problem remains that in order to start this process it is necessary to make some changes in each product so that the translation can be updated when we update the translation new lines appear there

Is it possible to run this process somehow automatically so that you don’t have to go into each product, make some changes there and then make changes to the translations?

or am I going the wrong way? Please tell me what would be more correct

THANK YOU!

December 19, 2023 at 4:22 am #15088195

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

Hi Yury,

You can go to Products > Select products in bulk and click on Update button to update products to sync the custom field value to the translation product.

Let me know how it goes.

Products ‹ WPML Testing — WordPress 2023-12-19 11-06-29.png
December 20, 2023 at 1:15 pm #15103083

yuryE

HI!

I am experiencing a very strange problem, there is no way for me to translate SKUs in a variant product.
I added the lines
<wpml-config>
<custom-fields>
<custom-field action="translate">sku</custom-field>
<custom-field action="translate">ref</custom-field>
</custom-fields>
</wpml-config>

into the configuration file to make the SKU field translatable to hidden link

If I edit a previously created product such as product descriptions, the SKU lines (wc_variation_field:_sku) for NOT appear in hidden link.

If I change (Add extra digits or characters that should not be present) in a previously created product SKU in a variation product, the SKU (wc_variation_field:_sku) lines for SKU (wc_variation_field:_sku) appear in hidden link.

But if I return the Correct SKU number then from the translations this wc_variation_field:_sku string disappears and the SKU Reappears as in the parent product, not as in the variation product in the Main language.

I am slowly going crazy, I have tried every possible way. Please I really need your help, I can provide all the accesses needed to log into the admin.

THANK YOU!

December 21, 2023 at 3:02 am #15106439

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

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

Hi,

The correct SKU field ID is "_sku", if you want to translate this field, the custom XML configuration code should be:

<custom-field action="translate">_sku</custom-field>

or you can manually set the translation preference field in WPML > Settings > Custom Fields Translation > Click on "Show system fields" and search for this field.

By default, the Advanced Translation Editor does not include the numeric value. If you want to translate this value, please add the code below to the file functions.php in the theme folder.

function wpmlsupp_7499_allow_translating_numbers( $is_translatable, $job_translate ) {
    $data = $job_translate['field_data'];
	if ( 'base64' === $job_translate['field_format'] ) {
		$data = base64_decode( $data );
	}
    if ( is_numeric( $data ) ) {
    	return true;
    }
    return $is_translatable;
}
add_filter( 'wpml_tm_job_field_is_translatable', 'wpmlsupp_7499_allow_translating_numbers', 10, 2 );

then make a small change to the product content > Save > Update the translation and search for the value.

However, the SKU defines a unique product on your site so it should be the same across languages.

Refer documentation
https://wpml.org/documentation/getting-started-guide/translating-custom-fields/
https://wpml.org/faq/how-to-translate-urls-shortcodes-and-html-attributes-using-the-advanced-translation-editor/

Look forward to your reply.
Thanks

December 21, 2023 at 10:48 am #15109035

yuryE

Thank you very much, your tips were incredibly helpful and I managed to achieve the result that I needed. Your technical support is amazing.

December 21, 2023 at 10:48 am #15109037

yuryE

Thank you very much, your tips were incredibly helpful and I managed to achieve the result that I needed. Your technical support is amazing.