Code Duplication    Length = 3-3 lines in 4 locations

includes/abstracts/abstract-wc-order.php 3 locations

@@ 773-775 (lines=3) @@
770
			wc_update_order_item_meta( $item_id, '_line_tax_data', array( 'total' => $line_taxes ) );
771
772
			// Sum the item taxes
773
			foreach ( array_keys( $shipping_taxes + $line_taxes ) as $key ) {
774
				$shipping_taxes[ $key ] = ( isset( $line_taxes[ $key ] ) ? $line_taxes[ $key ] : 0 ) + ( isset( $shipping_taxes[ $key ] ) ? $shipping_taxes[ $key ] : 0 );
775
			}
776
		}
777
778
		// Save tax totals
@@ 786-788 (lines=3) @@
783
		$this->remove_order_items( 'tax' );
784
785
		// Now merge to keep tax rows
786
		foreach ( array_keys( $taxes + $shipping_taxes ) as $tax_rate_id ) {
787
			$this->add_tax( $tax_rate_id, isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ] : 0, isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 );
788
		}
789
790
		return true;
791
	}
@@ 858-860 (lines=3) @@
855
		$this->remove_order_items( 'tax' );
856
857
		// Now merge to keep tax rows.
858
		foreach ( array_keys( $order_taxes + $order_shipping_taxes ) as $tax_rate_id ) {
859
			$this->add_tax( $tax_rate_id, isset( $order_taxes[ $tax_rate_id ] ) ? $order_taxes[ $tax_rate_id ] : 0, isset( $order_shipping_taxes[ $tax_rate_id ] ) ? $order_shipping_taxes[ $tax_rate_id ] : 0 );
860
		}
861
862
		// Save tax totals
863
		$this->set_total( WC_Tax::round( array_sum( $order_shipping_taxes ) ), 'shipping_tax' );

includes/class-wc-ajax.php 1 location

@@ 1639-1641 (lines=3) @@
1636
		$order->remove_order_items( 'tax' );
1637
1638
		// Add tax rows
1639
		foreach ( array_keys( $taxes + $shipping_taxes ) as $tax_rate_id ) {
1640
			$order->add_tax( $tax_rate_id, isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ] : 0, isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 );
1641
		}
1642
1643
		// Create the new order_taxes
1644
		foreach ( $order->get_taxes() as $tax_id => $tax_item ) {