Skip Navigation

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.

Our wait time is higher than usual, please make sure you are meeting the minimum requirement - https://wpml.org/home/minimum-requirements before you report issues, and if you can take a look at current Known Issues - https://wpml.org/known-issues/. Thank you.
Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

Tagged: 

This topic contains 0 replies, has 0 voices.

Last updated by marioG-45 23 hours, 54 minutes ago.

Assisted by: Dražen.

Author Posts
April 22, 2025 at 5:55 am #16953034

marioG-45

Background of the issue:
I am working on a site under development and trying to add an extra field using wcml_custom_prices_fields. The field appears properly, but after saving, its value does not appear. I am following the documentation at https://wpml.org/wcml-hook/wcml_custom_prices_fields/.

Symptoms:
The extra field added using wcml_custom_prices_fields appears properly but does not retain its value after saving.

Questions:
Why does the value of the extra field not appear after saving?

April 22, 2025 at 6:33 am #16953151

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

I have been able to reproduce the issue and have escalated it to our 2nd tier to check and advise further.

Regards,
Drazen

April 23, 2025 at 5:53 am #16957866

marioG-45

Hello,
Any luck on that issue?
Please let me know.
Thanks

April 23, 2025 at 6:09 am #16957874

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

it will take a day or two before I have any feedback.

I will update you when I have some news.

Regards,
Drazen

April 23, 2025 at 9:01 am #16958651

marioG-45

Hello

Thanks for your response. Waiting for good news 🙂

Thanks

April 24, 2025 at 5:50 am #16962468

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

[changing status of ticket]

April 24, 2025 at 12:01 pm #16964104

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

we checked, and you will also need to use wcml_update_custom_prices_values hook, for example:

add_filter( 'wcml_update_custom_prices_values', 'add_sign_up_fee_to_custom_prices', 10, 3 );
function add_sign_up_fee_to_custom_prices( $custom_prices, $code, $post_id ) {
	$sign_up_fee = get_post_meta( $post_id, '_sign_up_fee'.'_' . $code, true );
    if (isset($_POST["_custom_sign_up_fee"][$code])){
        $sign_up_fee = $_POST["_custom_sign_up_fee"][$code];
    }
	$custom_prices['_sign_up_fee'] = $sign_up_fee;
	return $custom_prices;
}

- https://wpml.org/wcml-hook/wcml_custom_prices_fields/

Regards,
Drazen

April 28, 2025 at 4:58 am #16973051

marioG-45

Hello there

I'm using the wcml_custom_prices_fields hook to create a custom field and try to store data. The field appears in the product, but after saving, the data is not storing.

Documentation link: https://wpml.org/wcml-hook/wcml_custom_prices_fields.
My code: hidden link.
Backend Screenshot: hidden link.

Why is the custom field data not storing after saving? That changes will come in new plugin update?

Could you please check it and let me know.
Thanks

April 28, 2025 at 11:33 am #16974601

marioG-45

Hi Dražen,
Are you there? I hope you are doing well.
Could you please check it on urgent basis.
Thanks

April 28, 2025 at 6:38 pm #16976535

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

I am not sure if you have maybe missed my reply above few days ago, you also need to use additional hook for prices to be saved / updated.

Please check my previous reply.

Let us know if anything else.

Regards,
Drazen

April 30, 2025 at 4:02 am #16981559

marioG-45

Hello Dražen,

As per your previous comment I have added below code.
add_filter( 'wcml_update_custom_prices_values', 'add_sign_up_fee_to_custom_prices', 10, 3 );
function add_sign_up_fee_to_custom_prices( $custom_prices, $code, $post_id ) {
$sign_up_fee = get_post_meta( $post_id, '_sign_up_fee'.'_' . $code, true );
if (isset($_POST["_custom_sign_up_fee"][$code])){
$sign_up_fee = $_POST["_custom_sign_up_fee"][$code];
}
$custom_prices['_sign_up_fee'] = $sign_up_fee;
return $custom_prices;
}

Did you checked my screenshot which I shared in previous comment. What you think I miss any hook or any code to save value?

Could you please check it and let me know.
Thanks

April 30, 2025 at 4:30 am #16981566

marioG-45

Hello Dražen,

I found more issue in the variable product. its only showing the currency symbol not showing the field label. Also its not saving the value just like the previous response.
Screenshot - hidden link

You can check below video for more understanding.
- hidden link

Thanks

April 30, 2025 at 5:29 am #16981603

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

one thing at time please.

For code, I shared with you, as I have this is example code you need to adjust it to your custom field names.

So, to make it more understandable, use hook wcml_custom_prices_fields to create custom fields, then use wcml_update_custom_prices_values to update these fields.

Note I am on vacation today, so I might not reply until tomorrow. You can also open new chat and ask my colleague to help out in the meantime.

Regards,
Drazen

April 30, 2025 at 11:08 am #16983370

marioG-45

Hello,

I am trying to save custom field data for a WooCommerce variable product using the WPML plugin. I have added custom price fields using the following code:

add_filter( 'wcml_custom_prices_fields', 'add_custom_price_fields', 10, 2 );
function add_custom_price_fields( $fields, $product_id ) {
// Add a new custom price field
$fields[] = '_purchase_cost';
return $fields;
}
add_filter( 'wcml_custom_prices_fields_labels', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $labels, $product_id ){
// Edit the label of a custom price field
$labels[ '_purchase_cost' ] = __( 'Purchase cost', 'woocommerce-multilingual' );
return $labels;
}
add_filter( 'wcml_update_custom_prices_values', 'add_purchase_cost_to_custom_prices', 10, 3 );
function add_purchase_cost_to_custom_prices( $custom_prices, $code, $post_id ) {
$purchase_cost = get_post_meta( $post_id, '_purchase_cost'.'_' . $code, true );
if (isset($_POST["_custom_purchase_cost"][$code])){
$purchase_cost = $_POST["_custom_purchase_cost"][$code];
}
$custom_prices['_purchase_cost'] = $purchase_cost;
return $custom_prices;
}

Screenshot: hidden link

Symptoms:
After saving the variable custom field data, the product page reloads, and I can't see anything. When I comment out the code, things work fine, but I can't see the custom field.

Questions:
Why does the product page reload and not display anything after saving the variable custom field data?
How can I save custom field data for a WooCommerce variable product without causing the page to reload incorrectly?

May 1, 2025 at 6:39 am #16985645

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks, I will need to check with our 2nd tier, since it could be different for variable products.

Regards,
Drazen