Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 2456-2481 (lines=26) @@
2453
	/**
2454
	 * Increase applied coupon counts.
2455
	 */
2456
	public function increase_coupon_usage_counts() {
2457
		if ( 'yes' == get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2458
			return;
2459
		}
2460
2461
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2462
2463
			foreach ( $this->get_used_coupons() as $code ) {
2464
				if ( ! $code ) {
2465
					continue;
2466
				}
2467
2468
				$coupon = new WC_Coupon( $code );
2469
2470
				$used_by = $this->get_user_id();
2471
2472
				if ( ! $used_by ) {
2473
					$used_by = $this->billing_email;
2474
				}
2475
2476
				$coupon->inc_usage_count( $used_by );
2477
			}
2478
2479
			update_post_meta( $this->id, '_recorded_coupon_usage_counts', 'yes' );
2480
		}
2481
	}
2482
2483
2484
	/**
@@ 2487-2513 (lines=27) @@
2484
	/**
2485
	 * Decrease applied coupon counts.
2486
	 */
2487
	public function decrease_coupon_usage_counts() {
2488
2489
		if ( 'yes' != get_post_meta( $this->id, '_recorded_coupon_usage_counts', true ) ) {
2490
			return;
2491
		}
2492
2493
		if ( sizeof( $this->get_used_coupons() ) > 0 ) {
2494
2495
			foreach ( $this->get_used_coupons() as $code ) {
2496
2497
				if ( ! $code ) {
2498
					continue;
2499
				}
2500
2501
				$coupon = new WC_Coupon( $code );
2502
2503
				$used_by = $this->get_user_id();
2504
				if ( ! $used_by ) {
2505
					$used_by = $this->billing_email;
2506
				}
2507
2508
				$coupon->dcr_usage_count( $used_by );
2509
			}
2510
2511
			delete_post_meta( $this->id, '_recorded_coupon_usage_counts' );
2512
		}
2513
	}
2514
2515
	/**
2516
	 * Reduce stock levels for all line items in the order.