Code Duplication    Length = 14-14 lines in 2 locations

modules/google-analytics/classes/wp-google-analytics-universal.php 2 locations

@@ 133-146 (lines=14) @@
130
131
		// Order items
132
		if ( $order->get_items() ) {
133
			foreach ( $order->get_items() as $item ) {
134
				$product = $order->get_product_from_item( $item );
135
				$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
136
137
				$item_details = array(
138
					'id' => $product_sku_or_id,
139
					'name' => $item['name'],
140
					'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
141
					'price' => $order->get_item_total( $item ),
142
					'quantity' => $item['qty'],
143
				);
144
				$command = "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );";
145
				array_push( $command_array, $command );
146
			}
147
		}
148
149
		// Order summary
@@ 380-393 (lines=14) @@
377
		$universal_commands = array();
378
		$cart = WC()->cart->get_cart();
379
380
		foreach ( $cart as $cart_item_key => $cart_item ) {
381
			/**
382
			* This filter is already documented in woocommerce/templates/cart/cart.php
383
			*/
384
			$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
385
			$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
386
387
			$item_details = array(
388
				'id' => $product_sku_or_id,
389
				'name' => $product->get_title(),
390
				'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
391
				'price' => $product->get_price(),
392
				'quantity' => $cart_item[ 'quantity' ]
393
			);
394
395
			array_push( $universal_commands, "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );" );
396
		}