add_filter( 'wcml_update_custom_prices_values', 'the_callback_function', 10, 2 );
- 유형
- filter
- 카테고리
- 다중 통화 기능
- WooCommerce Multilingual 버전
- 3.8
설명
저장하기 전에 두 번째 통화에 대한 사용자 정의 가격을 필터링하세요.
인수
이 필터에는 두 개의 매개변수가 전달됩니다.- $prices
- (array) 사용자 정의 가격 배열은 다음과 같습니다.
array( '_regular_price' => $regular_price, '_sale_price' => $sale_price, '_wcml_schedule' => $schedule, '_sale_price_dates_from' => $date_from, '_sale_price_dates_to' => $date_to )- $currency
- (string) 사용자 정의 가격을 저장할 두 번째 통화입니다(예: “USD”, “EUR” 등).
사용 예시
예제
/*
* Add this code to the functions.php file of your theme.
*
* Assume:
* EUR = the default currency
* USD = the second currency
*/
add_filter( 'wcml_update_custom_prices_values', 'update_custom_prices_values', 10, 2 );
function update_custom_prices_values( $prices, $currency ){
if( 'USD' == $currency ){
// Set the fixed USD custom sale price for all products when saving
$prices[ '_sale_price' ] = 49;
}
return $prices;
}
관련 훅
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_custom_prices_fields