woocommerce_delete_variations_on_product_type_change filter-hookWC 5.0.0

Filter to prevent variations from being deleted while switching from a variable product type to a variable product type.

Usage

add_filter( 'woocommerce_delete_variations_on_product_type_change', 'wp_kama_woocommerce_delete_variations_on_product_type_change_filter', 10, 3 );

/**
 * Function for `woocommerce_delete_variations_on_product_type_change` filter-hook.
 * 
 * @param bool       $condition A boolean value of true will delete the variations.
 * @param WC_Product $product   Product data.
 * @param            $to        
 *
 * @return bool
 */
function wp_kama_woocommerce_delete_variations_on_product_type_change_filter( $condition, $product, $to ){

	// filter...
	return $condition;
}
$condition(true|false)
A boolean value of true will delete the variations.
$product(WC_Product)
Product data.
$to
-

Changelog

Since 5.0.0 Introduced.

Where the hook is called

WC_Post_Data::product_type_changed()
woocommerce_delete_variations_on_product_type_change
woocommerce/includes/class-wc-post-data.php 148
if ( apply_filters( 'woocommerce_delete_variations_on_product_type_change', 'variable' === $from && 'variable' !== $to, $product, $from, $to ) ) {

Where the hook is used in WooCommerce

Usage not found.