Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 2566-2591 (lines=26) @@
2563
	/**
2564
	 * Increase applied coupon counts.
2565
	 */
2566
	public function increase_coupon_usage_counts() {
2567
		if ( 'yes' == get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2568
			return;
2569
		}
2570
2571
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2572
2573
			foreach ( $this->get_used_coupons() as $code ) {
2574
				if ( ! $code ) {
2575
					continue;
2576
				}
2577
2578
				$coupon = new WC_Coupon( $code );
2579
2580
				$used_by = $this->get_user_id();
2581
2582
				if ( ! $used_by ) {
2583
					$used_by = $this->billing_email;
2584
				}
2585
2586
				$coupon->inc_usage_count( $used_by );
2587
			}
2588
2589
			update_post_meta( $this->id, '_recorded_coupon_usage_counts', 'yes' );
2590
		}
2591
	}
2592
2593
2594
	/**
@@ 2597-2623 (lines=27) @@
2594
	/**
2595
	 * Decrease applied coupon counts.
2596
	 */
2597
	public function decrease_coupon_usage_counts() {
2598
2599
		if ( 'yes' != get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2600
			return;
2601
		}
2602
2603
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2604
2605
			foreach ( $this->get_used_coupons() as $code ) {
2606
2607
				if ( ! $code ) {
2608
					continue;
2609
				}
2610
2611
				$coupon = new WC_Coupon( $code );
2612
2613
				$used_by = $this->get_user_id();
2614
				if ( ! $used_by ) {
2615
					$used_by = $this->billing_email;
2616
				}
2617
2618
				$coupon->dcr_usage_count( $used_by );
2619
			}
2620
2621
			delete_post_meta( $this->id, '_recorded_coupon_usage_counts' );
2622
		}
2623
	}
2624
2625
	/**
2626
	 * Reduce stock levels for all line items in the order.