WC_Admin_List_Table_Products::add_variation_parents_for_shipping_class()
Modifies post query so that it includes parent products whose variations have particular shipping class assigned.
Метод класса: WC_Admin_List_Table_Products{}
Хуков нет.
Возвращает
Массив
. Array of products, including parents of variations.
Использование
$WC_Admin_List_Table_Products = new WC_Admin_List_Table_Products(); $WC_Admin_List_Table_Products->add_variation_parents_for_shipping_class( $pieces, $wp_query );
- $pieces(массив) (обязательный)
- Array of SELECT statement pieces (from, where, etc).
- $wp_query(WP_Query) (обязательный)
- WP_Query instance.
Код WC_Admin_List_Table_Products::add_variation_parents_for_shipping_class() WC Admin List Table Products::add variation parents for shipping class WC 9.3.1
public function add_variation_parents_for_shipping_class( $pieces, $wp_query ) { global $wpdb; if ( isset( $_GET['product_shipping_class'] ) && '0' !== $_GET['product_shipping_class'] ) { // WPCS: input var ok. $replaced_where = str_replace( ".post_type = 'product'", ".post_type = 'product_variation'", $pieces['where'] ); $pieces['where'] .= " OR {$wpdb->posts}.ID in ( SELECT {$wpdb->posts}.post_parent FROM {$wpdb->posts} LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id) WHERE 1=1 $replaced_where )"; return $pieces; } return $pieces; }