add_filter( 'wcml_custom_prices_fields_labels', 'the_callback_function', 10, 2 );
คำอธิบาย
- เพิ่มป้ายกำกับฟิลด์ราคาที่กำหนดเองลงในสินค้า
- ฟิลด์เหล่านี้จะแสดงในส่วน กำหนดราคาในสกุลเงินอื่นด้วยตนเอง เมื่อแก้ไข/สร้างสินค้าต้นฉบับ
- หากต้องการเพิ่มฟิลด์ราคาที่กำหนดเอง โปรดดูฮุก wcml_custom_prices_fields
อาร์กิวเมนต์
มีพารามิเตอร์ 2 ตัวที่ส่งไปยังฟิลเตอร์นี้:
$labelsarrayอาร์เรย์ป้ายกำกับฟิลด์ราคากำหนดเอง$product_idintegerID ของสินค้าต้นฉบับ
ตัวอย่างการใช้งาน
ใช้โค้ดตัวอย่างที่ให้ไว้ด้านล่างเพื่อให้ได้ผลลัพธ์ตามที่แสดงในภาพหน้าจอต่อไปนี้
/* * 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; }
