Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Kyiv (GMT+03:00)

This topic contains 1 reply, has 0 voices.

Last updated by Andrey 2 days, 18 hours 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;
}