Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 2438-2463 (lines=26) @@
2435
	/**
2436
	 * Increase applied coupon counts.
2437
	 */
2438
	public function increase_coupon_usage_counts() {
2439
		if ( 'yes' == get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2440
			return;
2441
		}
2442
2443
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2444
2445
			foreach ( $this->get_used_coupons() as $code ) {
2446
				if ( ! $code ) {
2447
					continue;
2448
				}
2449
2450
				$coupon = new WC_Coupon( $code );
2451
2452
				$used_by = $this->get_user_id();
2453
2454
				if ( ! $used_by ) {
2455
					$used_by = $this->billing_email;
2456
				}
2457
2458
				$coupon->inc_usage_count( $used_by );
2459
			}
2460
2461
			update_post_meta( $this->id, '_recorded_coupon_usage_counts', 'yes' );
2462
		}
2463
	}
2464
2465
2466
	/**
@@ 2469-2495 (lines=27) @@
2466
	/**
2467
	 * Decrease applied coupon counts.
2468
	 */
2469
	public function decrease_coupon_usage_counts() {
2470
2471
		if ( 'yes' != get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2472
			return;
2473
		}
2474
2475
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2476
2477
			foreach ( $this->get_used_coupons() as $code ) {
2478
2479
				if ( ! $code ) {
2480
					continue;
2481
				}
2482
2483
				$coupon = new WC_Coupon( $code );
2484
2485
				$used_by = $this->get_user_id();
2486
				if ( ! $used_by ) {
2487
					$used_by = $this->billing_email;
2488
				}
2489
2490
				$coupon->dcr_usage_count( $used_by );
2491
			}
2492
2493
			delete_post_meta( $this->id, '_recorded_coupon_usage_counts' );
2494
		}
2495
	}
2496
2497
	/**
2498
	 * Reduce stock levels for all line items in the order.