Skip to content

Commit

Permalink
Hide empty taxes by default.
Browse files Browse the repository at this point in the history
Closes #11050 @claudiosmweb
  • Loading branch information
mikejolley committed Jun 6, 2016
1 parent 7ec12cc commit 2d2a5eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions includes/abstracts/abstract-wc-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,11 @@ public function get_tax_totals() {
$tax_totals[ $code ]->formatted_amount = wc_price( wc_round_tax_total( $tax_totals[ $code ]->amount ), array('currency' => $this->get_order_currency()) );
}

if ( apply_filters( 'woocommerce_order_hide_zero_taxes', true ) ) {
$amounts = array_filter( wp_list_pluck( $tax_totals, 'amount' ) );
$tax_totals = array_intersect_key( $tax_totals, $amounts );
}

return apply_filters( 'woocommerce_order_tax_totals', $tax_totals, $this );
}

Expand Down
5 changes: 5 additions & 0 deletions includes/class-wc-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ public function get_tax_totals() {
}
}

if ( apply_filters( 'woocommerce_cart_hide_zero_taxes', true ) ) {
$amounts = array_filter( wp_list_pluck( $tax_totals, 'amount' ) );
$tax_totals = array_intersect_key( $tax_totals, $amounts );
}

return apply_filters( 'woocommerce_cart_tax_totals', $tax_totals, $this );
}

Expand Down

0 comments on commit 2d2a5eb

Please sign in to comment.