apply_filters( 'wcml_raw_price_amount', integer/float $price, string $currency )
- ประเภท
- filter
- หมวดหมู่
- ฟีเจอร์หลายสกุลเงิน
- เวอร์ชันของ WooCommerce Multilingual
- 3.5
คำอธิบาย
- แปลงราคาดิบในสกุลเงินเริ่มต้นเป็นสกุลเงินที่เลือก
- ควรใช้ฟิลเตอร์นี้สำหรับการกรองราคาสินค้า/รูปแบบสินค้าโดยทั่วไป
- สามารถใช้งานได้ในส่วนหน้าเว็บไซต์
ฟิลเตอร์นี้จะถูกใช้กับฟิลด์กำหนดเองของสินค้าและรูปแบบสินค้าที่ใช้สำหรับราคา (เมื่อถูกอ่านจากฐานข้อมูล):
- _price
- _regular_price
- _sale_price
- _min_variation_price
- _min_variation_price_regular_price
- _mix_variation_price_sale_price
- _max_variation_price
- _max_variation_price_regular_price
- _max_variation_price_sale_price
อาร์กิวเมนต์
- $price
- (integer/float) (จำเป็น) ราคาดิบในสกุลเงินเริ่มต้น
- $currency
- (string) (ตัวเลือก) รหัสสกุลเงินที่คุณต้องการแปลงราคาไปเป็น เช่น “USD”, “EUR” เป็นต้น หากไม่ได้ตั้งค่าพารามิเตอร์นี้ ระบบจะใช้สกุลเงินปัจจุบันที่ใช้บนส่วนหน้าเว็บไซต์
ตัวอย่างการใช้งาน
ตัวอย่าง
/*
Assume:
* USD = the default currency
* EUR = the second currency
* 0.8 = the exchange rate USD / EUR
*/
$price = 100;
$currency = "EUR";
$new_price = apply_filters('wcml_raw_price_amount', $price, $currency);
echo $new_price; // Return 80
ฮุกที่เกี่ยวข้อง
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