add_filter( 'wcml_product_custom_prices', 'the_callback_function', 10, 3 );
- ประเภท
- filter
- หมวดหมู่
- ฟีเจอร์หลายสกุลเงิน
- เวอร์ชันของ WooCommerce Multilingual
- 3.8.2
คำอธิบาย
กรองราคาแบบกำหนดเองที่ตั้งไว้สำหรับสินค้า
อาร์กิวเมนต์
มี 3 พารามิเตอร์ที่ส่งไปยังฟิลเตอร์นี้:- $custom_prices
- (array) อาร์เรย์ราคาแบบกำหนดเอง คีย์ประกอบด้วย:
'_price', '_regular_price', '_sale_price',
'_min_variation_price',
'_max_variation_price',
'_min_variation_regular_price', '_max_variation_regular_price',
'_min_variation_sale_price',
'_max_variation_sale_price'- $product_id
- (integer) ID ของสินค้า
- $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_product_custom_prices', 'change_product_custom_prices', 10, 3 );
function change_product_custom_prices( $custom_prices, $product_id, $currency ) {
// Change all custom prices in USD to 99
if ( 'USD' == $currency ) {
$custom_prices[ '_price' ] = 99;
}
return $custom_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_custom_prices_strings, wcml_switch_currency, wcml_custom_prices_fields, wcml_multi_currency_ajax_actions