WordPress at a glance
function is not described

WC_Admin_List_Table_Products::add_variation_parents_for_shipping_class() public WC 1.0

Modifies post query so that it includes parent products whose variations have particular shipping class assigned.

{} It's a method of the class: WC_Admin_List_Table_Products{}

No Hooks.


Array. 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) (required)
Array of SELECT statement pieces (from, where, etc).
$wp_query(WP_Query) (required)
WP_Query instance.

Code of WC_Admin_List_Table_Products::add_variation_parents_for_shipping_class() WC 5.4.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;