add_filter( 'wcml_variation_term_taxonomy_ids', 'the_callback_function' );
- ประเภท
- filter
- หมวดหมู่
- เบ็ดเตล็ด
- เวอร์ชันของ WooCommerce Multilingual
- 3.5
คำอธิบาย
- กรอง ID ของอนุกรมวิธานของตัวแปรที่เทอมสังกัดอยู่
- ส่วนขยาย WooCommerce บางตัวเพิ่มประเภทโพสต์ตัวแปรสินค้าที่กำหนดเองของตนเอง เช่น WooCommerce Subscriptions ฟิลเตอร์นี้ถูกใช้ในฟังก์ชันเพื่อตรวจสอบว่าสินค้าเป็นแบบมีตัวแปรหรือไม่ ซึ่งจะรวบรวม ID อนุกรมวิธานของตัวแปรทั้งหมดที่เทอมสังกัดอยู่ สำหรับสินค้าแบบมีตัวแปร
อาร์กิวเมนต์
มีเพียงพารามิเตอร์เดียวที่ส่งไปยังฟิลเตอร์นี้: term_taxonomy_ids- $term_taxonomy_ids
- (array) อาร์เรย์ที่ประกอบด้วย ID เทอมของอนุกรมวิธานของประเภทสินค้าแบบมีตัวเลือก
ตัวอย่างการใช้งาน
ตัวอย่าง
/**
* This example is extracted from the WooCommerce Subscriptions compatibility class in the WCML code.
* This WooCommerce extension has its own variable product type called "variable-subscription"
*/
add_filter('wcml_variation_term_taxonomy_ids', 'add_wcml_variation_term_taxonomy_ids');
function add_wcml_variation_term_taxonomy_ids($get_variation_term_taxonomy_ids){
global $wpdb;
$get_variation_term_taxonomy_id = $wpdb->get_var("SELECT tt.term_taxonomy_id FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.slug = 'variable-subscription'");
if(!empty($get_variation_term_taxonomy_id)){
$get_variation_term_taxonomy_ids[] = $get_variation_term_taxonomy_id;
}
return $get_variation_term_taxonomy_ids;
}
ฮุกที่เกี่ยวข้อง
wcml_new_order_admin_email_language, translate_shipping_methods_in_package, wcml_gui_additional_box_html, wcml_current_gateway_language, wcml_is_attributes_page, wcml_is_variable_product, wcml_gui_additional_box_data, wcml_after_load_lock_fields_js, wcml_wc_installed_pages, wcml_not_display_single_fields_to_translate