Fix filter woocommerce_shipping_rate_cost backwards compatible with cart taxes #28008

This commit is contained in:
OlegApanovich 2020-11-19 00:31:51 +02:00
parent 581f57b8f4
commit 1075382575
1 changed files with 6 additions and 0 deletions

View File

@ -82,7 +82,13 @@ class WC_Tax {
* @return array * @return array
*/ */
public static function calc_shipping_tax( $price, $rates ) { public static function calc_shipping_tax( $price, $rates ) {
// Backwards compatible from WC_Shipping_Rate::get_cost().
if ( has_filter( 'woocommerce_shipping_rate_cost' ) ) {
$rate = new WC_Shipping_Rate();
$price = $rate->get_cost();
}
$taxes = self::calc_exclusive_tax( $price, $rates ); $taxes = self::calc_exclusive_tax( $price, $rates );
return apply_filters( 'woocommerce_calc_shipping_tax', $taxes, $price, $rates ); return apply_filters( 'woocommerce_calc_shipping_tax', $taxes, $price, $rates );
} }