add_filter( 'wcml_custom_prices_fields', 'the_callback_function', 10, 2 );
- タイプ
- filter
- カテゴリー
- 多通貨機能
- WooCommerce Multilingualバージョン
- 3.8
説明
- 商品に追加のカスタム価格フィールドを追加します。
- オリジナルの商品を編集または作成する際、これらのフィールドは「他の通貨の価格を手動で設定」セクションに表示されます。
- カスタム価格フィールドのラベルを追加するには、wcml_custom_prices_fields_labelsフックを参照してください。
引数
このフィルターには2つのパラメーターが渡されます。- $fields
- (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_custom_prices_fields_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_multi_currency_ajax_actions
