WPML
add_filter( 'wcml_custom_prices_fields_labels', 'the_callback_function', 10, 2 );
Тип
filter
Версия WooCommerce Multilingual
3.8

Описание

  • Добавьте ярлыки произвольных полей цен к товарам.
  • Эти поля отображаются в разделе Set prices in other currencies manually при изменении/создании оригинальных товаров.
  • Чтобы добавить произвольные поля цен, см. хук wcml_custom_prices_fields.

Аргументы

В этот фильтр передаются два параметра:
$labels
(array) Массив меток произвольных полей цен.
$product_id
(integer) ID оригинального товара.

Пример использования

Используйте приведенный ниже пример кода, чтобы получить результаты, показанные на следующем снимке экрана.

произвольные поля цен

Пример
/*
 * 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;

}

wcml_is_cache_enabled_for_switching_currency, wcml_geolocation_get_user_country, wcml_user_store_strategy, wcml_rounded_price, wcml_currencies_without_cents, wcml_product_custom_prices, wcml_custom_prices_strings, wcml_switch_currency, wcml_custom_prices_fields, wcml_multi_currency_ajax_actions

Все хуки категории «Функция мультивалютности» (24) →