Code Duplication    Length = 14-14 lines in 2 locations

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

@@ 125-138 (lines=14) @@
122
123
		// Order items
124
		if ( $order->get_items() ) {
125
			foreach ( $order->get_items() as $item ) {
126
				$product = $order->get_product_from_item( $item );
127
				$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
128
129
				$item_details = array(
130
					'id' => $product_sku_or_id,
131
					'name' => $item['name'],
132
					'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
133
					'price' => $order->get_item_total( $item ),
134
					'quantity' => $item['qty'],
135
				);
136
				$command = "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );";
137
				array_push( $command_array, $command );
138
			}
139
		}
140
141
		// Order summary
@@ 368-381 (lines=14) @@
365
		$universal_commands = array();
366
		$cart = WC()->cart->get_cart();
367
368
		foreach ( $cart as $cart_item_key => $cart_item ) {
369
			/**
370
			* This filter is already documented in woocommerce/templates/cart/cart.php
371
			*/
372
			$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
373
			$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
374
375
			$item_details = array(
376
				'id' => $product_sku_or_id,
377
				'name' => $product->get_title(),
378
				'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
379
				'price' => $product->get_price(),
380
				'quantity' => $cart_item[ 'quantity' ]
381
			);
382
383
			array_push( $universal_commands, "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );" );
384
		}