Code Duplication    Length = 14-14 lines in 2 locations

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

@@ 143-156 (lines=14) @@
140
141
		// Order items
142
		if ( $order->get_items() ) {
143
			foreach ( $order->get_items() as $item ) {
144
				$product = $order->get_product_from_item( $item );
145
				$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
146
147
				$item_details = array(
148
					'id' => $product_sku_or_id,
149
					'name' => $item['name'],
150
					'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
151
					'price' => $order->get_item_total( $item ),
152
					'quantity' => $item['qty'],
153
				);
154
				$command = "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );";
155
				array_push( $command_array, $command );
156
			}
157
		}
158
159
		// Order summary
@@ 414-427 (lines=14) @@
411
		$universal_commands = array();
412
		$cart = WC()->cart->get_cart();
413
414
		foreach ( $cart as $cart_item_key => $cart_item ) {
415
			/**
416
			* This filter is already documented in woocommerce/templates/cart/cart.php
417
			*/
418
			$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
419
			$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
420
421
			$item_details = array(
422
				'id' => $product_sku_or_id,
423
				'name' => $product->get_title(),
424
				'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
425
				'price' => $product->get_price(),
426
				'quantity' => $cart_item[ 'quantity' ]
427
			);
428
429
			array_push( $universal_commands, "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );" );
430
		}