WPML
apply_filters( 'wcml_formatted_price', integer/float $price, string $currency )
ประเภท
filter
เวอร์ชันของ WooCommerce Multilingual
3.5

คำอธิบาย

แปลงราคาในสกุลเงินเริ่มต้นเป็นสกุลเงินที่เลือก โดยใช้รูปแบบที่ถูกต้อง

อาร์กิวเมนต์

$price
(integer/float) (จำเป็น) ราคาดิบในสกุลเงินเริ่มต้น
$currency
(string) (ไม่บังคับ) รหัสสกุลเงินที่คุณต้องการแปลงราคา เช่น “USD” “EUR” เป็นต้น หากไม่ได้ตั้งค่าพารามิเตอร์นี้ ระบบจะใช้สกุลเงินปัจจุบันที่ใช้ในส่วนหน้าเว็บไซต์

ตัวอย่างการใช้งาน

ตัวอย่าง
/*
Assume: 
 * EUR = the default currency
 * USD = the second currency
 * 1.2 = the exchange rate EUR / USD 
*/ 

$price = 1234.56;
$currency = 'USD';
$formatted_price = apply_filters( 'wcml_formatted_price', $price, $currency );

echo $formatted_price; // Return $1,481.47

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

ฮุก ฟีเจอร์หลายสกุลเงิน ทั้งหมด 24 รายการ →