apply_filters( 'wcml_formatted_price', integer/float $price, string $currency )
- Loại
- filter
- Danh mục
- Tính năng đa tiền tệ
- Phiên bản WooCommerce Multilingual
- 3.5
Miêu tả
Chuyển đổi giá ở tiền tệ mặc định sang tiền tệ được chọn, sử dụng định dạng chính xác.
Đối số
- $price
- (integer/float) (Bắt buộc) Giá thô bằng tiền tệ mặc định.
- $currency
- (string) (Tùy chọn) Mã tiền tệ mà bạn muốn chuyển đổi giá sang, ví dụ: “USD”, “EUR”, v.v. Nếu tham số này không được thiết lập, tiền tệ hiện tại được sử dụng trên giao diện người dùng sẽ được sử dụng.
Ví dụ sử dụng
Ví dụ
/* 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
Các hook liên quan
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