woocommerce_delete_variations_on_product_type_change
Filter to prevent variations from being deleted while switching from a variable product type to a variable product type.
Использование
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
- -
Список изменений
С версии 5.0.0 | Введена. |
Где вызывается хук
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 ) ) {