woocommerce_variable_children_args filter-hookWC 3.0.0

Filters the query arguments used to retrieve variation children of a variable product.

Usage

add_filter( 'woocommerce_variable_children_args', 'wp_kama_woocommerce_variable_children_args_filter', 10, 3 );

/**
 * Function for `woocommerce_variable_children_args` filter-hook.
 * 
 * @param array      $args         Query arguments for get_posts().
 * @param WC_Product $product      The variable product object.
 * @param bool       $visible_only True when retrieving only visible variations, false for all variations.
 *
 * @return array
 */
function wp_kama_woocommerce_variable_children_args_filter( $args, $product, $visible_only ){

	// filter...
	return $args;
}
$args(array)
Query arguments for get_posts().
$product(WC_Product)
The variable product object.
$visible_only(true|false)
True when retrieving only visible variations, false for all variations.

Changelog

Since 3.0.0 Introduced.

Where the hook is called

WC_Product_Variable_Data_Store_CPT::read_children()
woocommerce_variable_children_args
woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php 197
$children['all'] = get_posts( apply_filters( 'woocommerce_variable_children_args', $all_args, $product, false ) );
woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php 200
$children['visible'] = get_posts( apply_filters( 'woocommerce_variable_children_args', $visible_only_args, $product, true ) );

Where the hook is used in WooCommerce

Usage not found.