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?
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.