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フックを参照してください。

引数

このフィルターには2つのパラメーターが渡されます。
$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件) →