Code Duplication    Length = 9-10 lines in 2 locations

includes/class-wc-cart-coupons.php 2 locations

@@ 74-83 (lines=10) @@
71
	 */
72
	public function check_coupons() {
73
		foreach ( $this->coupons as $code => $coupon ) {
74
			if ( ! $coupon->is_valid() ) {
75
				$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_INVALID_REMOVED );
76
				$this->remove_coupon( $code );
77
				WC()->session->set( 'refresh_totals', true );
78
			}
79
		}
80
	}
81
82
	/**
83
	 * Check for user coupons (now that we have billing email). If a coupon is invalid, add an error.
84
	 * @param array $posted
85
	 */
86
	public function check_customer_restriction( $posted ) {
@@ 136-144 (lines=9) @@
133
					$usage_count = $usage_count + sizeof( array_keys( $used_by, $check_email ) );
134
				}
135
136
				if ( $usage_count >= $coupon->get_usage_limit_per_user() ) {
137
					$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_USAGE_LIMIT_REACHED );
138
					$this->remove_coupon( $code );
139
					WC()->session->set( 'refresh_totals', true );
140
				}
141
			}
142
		}
143
	}
144
145
	/**
146
	 * Add a message for the applied coupon.
147
	 * @param  string $code