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.