WPML
add_filter( 'wcml_custom_prices_fields', 'the_callback_function', 10, 2 );
ประเภท
filter
เวอร์ชันของ WooCommerce Multilingual
3.8

คำอธิบาย

  • เพิ่มฟิลด์ราคากำหนดเองเพิ่มเติมลงในผลิตภัณฑ์
  • ฟิลด์เหล่านี้จะแสดงในส่วน กำหนดราคาในสกุลเงินอื่นด้วยตนเอง เมื่อแก้ไข/สร้างผลิตภัณฑ์ต้นฉบับ
  • หากต้องการเพิ่มป้ายกำกับฟิลด์ราคากำหนดเอง โปรดดูที่ฮุก wcml_custom_prices_fields_labels

อาร์กิวเมนต์

มีพารามิเตอร์สองตัวที่ส่งผ่านไปยังฟิลเตอร์นี้:
$fields
(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_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_multi_currency_ajax_actions

ฮุก ฟีเจอร์หลายสกุลเงิน ทั้งหมด 24 รายการ →