WPML
SignaturePHP
add_filter( 'wcml_custom_prices_fields_labels', 'the_callback_function', 10, 2 );

Description

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

Arguments

There are two parameters passed to this filter:

  • $labelsarray

    The custom price field label array.
  • $product_idinteger

    The ID of an original product.

Example Usage

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

custom-price-fields

PHP
/*
 * 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;

}