Code Duplication    Length = 5-9 lines in 3 locations

includes/forms/functions.php 1 location

@@ 795-800 (lines=6) @@
792
793
	$amount = 0.00;
794
795
	foreach ( $prices as $price ) {
796
		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
797
			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
798
			break;
799
		};
800
	}
801
802
	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
803
}

includes/misc-functions.php 1 location

@@ 1881-1885 (lines=5) @@
1878
		if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) {
1879
			$prices     = (array) $form->get_prices();
1880
			$price_text = array();
1881
			foreach ( $prices as $key => $price ) {
1882
				if ( isset( $price['_give_id']['level_id'] ) ) {
1883
					$price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' );
1884
				}
1885
			}
1886
1887
			if ( ! in_array( $data['form_level'], $price_text ) ) {
1888

includes/payments/class-give-payment.php 1 location

@@ 1011-1019 (lines=9) @@
1008
				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1009
				$donation_amount = '';
1010
				// Loop through prices.
1011
				foreach ( $prices as $price ) {
1012
					// Find a match between price_id and level_id.
1013
					// First verify array keys exists THEN make the match.
1014
					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1015
					     && $args['price_id'] == $price['_give_id']['level_id']
1016
					) {
1017
						$donation_amount = $price['_give_amount'];
1018
					}
1019
				}
1020
				// Fallback to the lowest price point.
1021
				if ( $donation_amount == '' ) {
1022
					$donation_amount  = give_get_lowest_price_option( $donation->ID );