added actions and filters to modify tax calculation for shipping taxes and fee taxes #16938

Filters and actions are needed to ensure correct tax calculation by
German law.

The filter in class-wc-cart-totals.php is used to modify fee tax
calculation during checkout and in cart.

The actions in the other files are used to modify tax calculation in
backend for manual orders.
This commit is contained in:
lars 2017-09-28 12:52:55 +02:00
parent 3052a91f28
commit 73bc8b8e6c
4 changed files with 11 additions and 0 deletions

View File

@ -313,6 +313,8 @@ final class WC_Cart_Totals {
} }
} }
$fee->taxes = apply_filters( 'woocommerce_get_fees_from_cart_taxes', $fee->taxes, $fee, $this );
$fee->total_tax = array_sum( $fee->taxes ); $fee->total_tax = array_sum( $fee->taxes );
if ( ! $this->round_at_subtotal() ) { if ( ! $this->round_at_subtotal() ) {

View File

@ -96,6 +96,9 @@ class WC_Order_Item_Fee extends WC_Order_Item {
} else { } else {
$this->set_taxes( false ); $this->set_taxes( false );
} }
do_action( 'woocommerce_order_item_fee_after_calculate_taxes', $this, $calculate_tax_for );
return true; return true;
} }

View File

@ -46,6 +46,9 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
} else { } else {
$this->set_taxes( false ); $this->set_taxes( false );
} }
do_action( 'woocommerce_order_item_shipping_after_calculate_taxes', $this, $calculate_tax_for );
return true; return true;
} }

View File

@ -223,6 +223,9 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
} else { } else {
$this->set_taxes( false ); $this->set_taxes( false );
} }
do_action( 'woocommerce_order_item_after_calculate_taxes', $this, $calculate_tax_for );
return true; return true;
} }