Skip to content Skip to sidebar

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

Problem:
You have built a custom plugin for WooCommerce and added extra fields like 'Pieces per box', 'Enable custom calculation', 'Piece Height (cm)', and 'Piece Width (cm)'. You want these fields to remain consistent across all languages and be locked with a message indicating that WPML will copy its value from the original language. However, you are unable to lock these custom fields for all languages.
Solution:
To lock custom fields in WooCommerce to ensure they remain the same across all languages, you can use the

wcml_js_lock_fields_classes

filter. This filter allows you to specify which custom field classes should be locked in the WooCommerce native product editor for translated products. You need to add this code to the functions.php file of your theme or within your custom plugin.

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_js_lock_fields_classes', 'add_js_lock_fields_classes' );
 
function add_js_lock_fields_classes( $classes ){
 
    // Add 2 locked field classes
    $classes[] = '_per_product_pricing_bto';
    $classes[] = '_per_product_shipping_bto';
 
    return $classes;
}

For more details, please refer to our documentation: https://wpml.org/wcml-hook/wcml_js_lock_fields_classes/

If this solution does not apply to your case, or if it seems outdated, 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. If you still need assistance, please 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.

This topic contains 1 reply, has 0 voices.

Last updated by Andrey 2 weeks, 2 days ago.

Assisted by: Andrey.

Author Posts
July 24, 2025 at 6:54 am #17265995

vokos-monoprosopi-saV

Background of the issue:
I have built a custom plugin for WooCommerce on my site hidden link. In the product management for this plugin, I have added some extra fields: 'Pieces per box', 'Enable custom calculation' (checkbox), 'Piece Height (cm)', and 'Piece Width (cm)'. I want these fields to remain the same across all languages and be locked with the message 'This field is locked for editing because WPML will copy its value from the original language.'

Symptoms:
I am unable to lock the custom fields for all languages so that they remain the same and do not change from language to language.

Questions:
How can I lock custom fields in WooCommerce so they remain the same across all languages using WPML?

July 24, 2025 at 8:24 am #17266415

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for contacting WPML support.

In WPML and WooCommerce Multilingual (WCML), specific custom fields, such as stock and price, are locked by default to ensure consistency across all translated versions of a product. However, you can customize which fields are locked or unlocked according to your needs.

To control this behavior, you can use the wcml_js_lock_fields_classes filter in your theme’s functions.php file or within your custom plugin. This hook allows you to add or remove custom field classes that are locked in the WooCommerce native product editor for translated products.

For more details, please refer to our documentation:
https://wpml.org/wcml-hook/wcml_js_lock_fields_classes/

Example

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_js_lock_fields_classes', 'add_js_lock_fields_classes' );
 
function add_js_lock_fields_classes( $classes ){
 
    // Add 2 locked field classes
    $classes[] = '_per_product_pricing_bto';
    $classes[] = '_per_product_shipping_bto';
 
    return $classes;
}