Skip Navigation
availability:

WooCommerce Multilingual Version: 3.8

description:
  • Add custom price field labels to products.
  • These fields are displayed in the Set prices in other currencies manually section when editing/creating original products.
  • To add custom price fields, see the wcml_custom_prices_fields hook.
type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_custom_prices_fields_labels', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$labels
(array) The custom price field label array.
$product_id
(integer) The ID of an original product.
hook example usage:

Use the example code provided below to get results shown in the following screenshot.

custom-price-fields

Example

/*
 * Add this code to the functions.php file of your theme.
 */
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[] = '_sign_up_fee'; 

    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[ '_sign_up_fee' ] = __( 'Sign-up Fee', 'woocommerce-multilingual' ); 

    return $labels;

}