WPML
apply_filters( 'wcml_product_price_by_currency', integer $product_id, string $currency )
Loại
filter
Phiên bản WooCommerce Multilingual
3.9

Miêu tả

  • Hook này trả về giá tùy chỉnh nếu được nhập. Nếu không, nó trả về giá dựa trên tỷ giá hối đoái đã thiết lập.
  • Hook này chỉ hoạt động trên giao diện người dùng.

Đối số

$product_id
(số nguyên) (Bắt buộc) ID sản phẩm
$currency
(chuỗi) (Bắt buộc) Mã tiền tệ mà bạn muốn lấy giá, ví dụ: “USD”, “EUR”, v.v.

Ví dụ sử dụng

Ví dụ
 // Get the EUR price of the product ID = 80 
$product_id = 80; 
$currency = 'EUR'; 
echo apply_filters( 'wcml_product_price_by_currency', $product_id, $currency );
 
Lưu ý: Mã Đa tiền tệ không phải lúc nào cũng được tải. Nếu bạn thấy bộ lọc này không hoạt động, vui lòng xem qua hook wcml_load_multi_currency_in_ajax.

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

Tất cả 24 hook Tính năng đa tiền tệ →