add_filter( 'wcml_custom_prices_fields_labels', 'the_callback_function', 10, 2 );
- ประเภท
- filter
- หมวดหมู่
- ฟีเจอร์หลายสกุลเงิน
- เวอร์ชันของ WooCommerce Multilingual
- 3.8
คำอธิบาย
- เพิ่มป้ายกำกับฟิลด์ราคาที่กำหนดเองลงในสินค้า
- ฟิลด์เหล่านี้จะแสดงในส่วน กำหนดราคาในสกุลเงินอื่นด้วยตนเอง เมื่อแก้ไข/สร้างสินค้าต้นฉบับ
- หากต้องการเพิ่มฟิลด์ราคาที่กำหนดเอง โปรดดูฮุก wcml_custom_prices_fields
อาร์กิวเมนต์
มีพารามิเตอร์ 2 ตัวที่ส่งไปยังฟิลเตอร์นี้:- $labels
- (array) อาร์เรย์ป้ายกำกับฟิลด์ราคากำหนดเอง
- $product_id
- (integer) ID ของสินค้าต้นฉบับ
ตัวอย่างการใช้งาน
ใช้โค้ดตัวอย่างที่ให้ไว้ด้านล่างเพื่อให้ได้ผลลัพธ์ตามที่แสดงในภาพหน้าจอต่อไปนี้
ตัวอย่าง
/*
* Add this code to the functions.php file of your theme.
*/
add_filter( 'wcml_custom_prices_fields', 'add_custom_price_fields', 10, 2 );
function add_custom_price_fields( $fields, $product_id ) {
// Add a new custom price field
$fields[] = '_sign_up_fee';
return $fields;
}
add_filter( 'wcml_custom_prices_fields_labels', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $labels, $product_id ){
// Edit the label of a custom price field
$labels[ '_sign_up_fee' ] = __( 'Sign-up Fee', 'woocommerce-multilingual' );
return $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, wcml_multi_currency_ajax_actions
