WC_Tax::maybe_remove_tax_class_rates()public staticWC 1.0

Deprecated from version 3.7.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

When the woocommerce_tax_classes option is changed, remove any orphan rates.

Method of the class: WC_Tax{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_Tax::maybe_remove_tax_class_rates( $old_value, $value );
$old_value(string) (required)
Old rates value.
$value(string) (required)
New rates value.

Changelog

Deprecated since 3.7.0

WC_Tax::maybe_remove_tax_class_rates() code WC 8.7.0

public static function maybe_remove_tax_class_rates( $old_value, $value ) {
	wc_deprecated_function( 'WC_Tax::maybe_remove_tax_class_rates', '3.7', 'WC_Tax::delete_tax_class_by' );

	$tax_classes          = array_filter( array_map( 'trim', explode( "\n", $value ) ) );
	$existing_tax_classes = self::get_tax_classes();
	$removed              = array_diff( $existing_tax_classes, $tax_classes );
	foreach ( $removed as $name ) {
		self::delete_tax_class_by( 'name', $name );
	}
}