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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by lisetteE-2 2 weeks, 1 day ago.

Assigned support staff: Bruno.

Author Posts
October 2, 2019 at 12:39 pm #4680203

lisetteE-2

I have added a custom field (via functions.php) for 'packing unit'. When there is value in the field in want to display the information on the productpage. So far so good. The 'packing unit' value is the same for german and english language. So I added a code to lock this custom field in the hope that value will be saved to the 'secondary' language too. I see that the field is locked but the value that I've put in on the german version does not get saved, and thus not shown in the english variant.

Link to a page where the issue can be seen:
hidden link (german)
frontend: hidden link
backend: hidden link

hidden link (english)
frontend: hidden link
backend: hidden link (no value in de locked field)

I used the following code in functions.php - I also locked the EAN (gtin) field:
// Lock EAN-field & Packung unit-field
add_filter( 'wcml_js_lock_fields_ids', 'add_js_lock_fields_ids' );

function add_js_lock_fields_ids( $ids ){

// Add lock to *_wpm_gtin_code* and *_text_field_packing_unit* field
$ids[] = '_wpm_gtin_code';
$ids[] = '_text_field_packing_unit';

return $ids;

}

So my goal is to only fill the german field en that this value is also save in the english variant.

October 2, 2019 at 7:17 pm #4682847

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for contacting us. To synchronize the values you would need to select the "Copy" option for the desired custom fields.

You can see in more detail in our documentation: https://wpml.org/documentation/getting-started-guide/translating-custom-fields/

Using Translation Management's "Copy" feature, the values would be synchronized between the default language and secondary languages.

To do exactly what you want you would need to know if there is any value in the secondary language to lock then.

Thank you.

October 8, 2019 at 9:29 am #4713599

lisetteE-2

My issue is resolved now. Thank you!