Logic error with used id

This commit is contained in:
Mike Jolley 2017-02-23 15:25:49 +00:00
parent 134df2f4a0
commit c5697f2d59
1 changed files with 4 additions and 4 deletions

View File

@ -1087,13 +1087,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $existing_taxes as $tax ) { foreach ( $existing_taxes as $tax ) {
// Remove taxes which no longer exist for cart/shipping. // Remove taxes which no longer exist for cart/shipping.
if ( ! array_key_exists( $tax->get_rate_id(), $cart_taxes ) && ! array_key_exists( $tax->get_rate_id(), $shipping_taxes ) || in_array( $tax->get_rate_id(), $saved_rate_ids ) ) { if ( ( ! array_key_exists( $tax->get_rate_id(), $cart_taxes ) && ! array_key_exists( $tax->get_rate_id(), $shipping_taxes ) ) || in_array( $tax->get_rate_id(), $saved_rate_ids ) ) {
$this->remove_item( $tax->get_id() ); $this->remove_item( $tax->get_id() );
continue; continue;
} }
$saved_rate_ids[] = $tax_rate_id; $saved_rate_ids[] = $tax->get_rate_id();
$tax->set_tax_total( isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] : 0 ); $tax->set_tax_total( isset( $cart_taxes[ $tax->get_rate_id() ] ) ? $cart_taxes[ $tax->get_rate_id() ] : 0 );
$tax->set_shipping_tax_total( ! empty( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 ); $tax->set_shipping_tax_total( ! empty( $shipping_taxes[ $tax->get_rate_id() ] ) ? $shipping_taxes[ $tax->get_rate_id() ] : 0 );
$tax->save(); $tax->save();
} }