Code Duplication    Length = 3-3 lines in 4 locations

includes/class-wc-ajax.php 1 location

@@ 1630-1632 (lines=3) @@
1627
		$order->remove_order_items( 'tax' );
1628
1629
		// Add tax rows
1630
		foreach ( array_keys( $taxes + $shipping_taxes ) as $tax_rate_id ) {
1631
			$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 );
1632
		}
1633
1634
		// Create the new order_taxes
1635
		foreach ( $order->get_taxes() as $tax_id => $tax_item ) {

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

@@ 794-796 (lines=3) @@
791
			wc_update_order_item_meta( $item_id, '_line_tax_data', array( 'total' => $line_taxes ) );
792
793
			// Sum the item taxes
794
			foreach ( array_keys( $shipping_taxes + $line_taxes ) as $key ) {
795
				$shipping_taxes[ $key ] = ( isset( $line_taxes[ $key ] ) ? $line_taxes[ $key ] : 0 ) + ( isset( $shipping_taxes[ $key ] ) ? $shipping_taxes[ $key ] : 0 );
796
			}
797
		}
798
799
		// Save tax totals
@@ 807-809 (lines=3) @@
804
		$this->remove_order_items( 'tax' );
805
806
		// Now merge to keep tax rows
807
		foreach ( array_keys( $taxes + $shipping_taxes ) as $tax_rate_id ) {
808
			$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 );
809
		}
810
811
		return true;
812
	}
@@ 879-881 (lines=3) @@
876
		$this->remove_order_items( 'tax' );
877
878
		// Now merge to keep tax rows.
879
		foreach ( array_keys( $order_taxes + $order_shipping_taxes ) as $tax_rate_id ) {
880
			$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 );
881
		}
882
883
		// Save tax totals
884
		$this->set_total( WC_Tax::round( array_sum( $order_shipping_taxes ) ), 'shipping_tax' );