Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 2545-2570 (lines=26) @@
2542
	/**
2543
	 * Increase applied coupon counts.
2544
	 */
2545
	public function increase_coupon_usage_counts() {
2546
		if ( 'yes' == get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2547
			return;
2548
		}
2549
2550
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2551
2552
			foreach ( $this->get_used_coupons() as $code ) {
2553
				if ( ! $code ) {
2554
					continue;
2555
				}
2556
2557
				$coupon = new WC_Coupon( $code );
2558
2559
				$used_by = $this->get_user_id();
2560
2561
				if ( ! $used_by ) {
2562
					$used_by = $this->billing_email;
2563
				}
2564
2565
				$coupon->inc_usage_count( $used_by );
2566
			}
2567
2568
			update_post_meta( $this->id, '_recorded_coupon_usage_counts', 'yes' );
2569
		}
2570
	}
2571
2572
2573
	/**
@@ 2576-2602 (lines=27) @@
2573
	/**
2574
	 * Decrease applied coupon counts.
2575
	 */
2576
	public function decrease_coupon_usage_counts() {
2577
2578
		if ( 'yes' != get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2579
			return;
2580
		}
2581
2582
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2583
2584
			foreach ( $this->get_used_coupons() as $code ) {
2585
2586
				if ( ! $code ) {
2587
					continue;
2588
				}
2589
2590
				$coupon = new WC_Coupon( $code );
2591
2592
				$used_by = $this->get_user_id();
2593
				if ( ! $used_by ) {
2594
					$used_by = $this->billing_email;
2595
				}
2596
2597
				$coupon->dcr_usage_count( $used_by );
2598
			}
2599
2600
			delete_post_meta( $this->id, '_recorded_coupon_usage_counts' );
2601
		}
2602
	}
2603
2604
	/**
2605
	 * Reduce stock levels for all line items in the order.