WPML
add_filter( 'wcml_custom_prices_fields', 'the_callback_function', 10, 2 );
유형
filter
카테고리
다중 통화 기능
WooCommerce Multilingual 버전
3.8

설명

  • 제품에 추가적인 사용자 정의 가격 필드를 추가합니다.
  • 이 필드는 원본 제품을 편집하거나 생성할 때 다른 통화로 가격 수동 설정 섹션에 표시됩니다.
  • 사용자 정의 가격 필드 레이블을 추가하려면 wcml_custom_prices_fields_labels 훅을 참조하세요.

인수

이 필터에는 두 개의 매개변수가 전달됩니다.
$fields
(배열) 사용자 정의 가격 필드 배열입니다.
$product_id
(정수) 원본 상품의 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

모든 다중 통화 기능 훅 24개 →