Code Duplication    Length = 5-9 lines in 3 locations

includes/import-functions.php 1 location

@@ 102-106 (lines=5) @@
99
		if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) {
100
			$prices     = (array) $form->get_prices();
101
			$price_text = array();
102
			foreach ( $prices as $key => $price ) {
103
				if ( isset( $price['_give_id']['level_id'] ) ) {
104
					$price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' );
105
				}
106
			}
107
108
			if ( ! in_array( $data['form_level'], $price_text ) ) {
109

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

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

includes/forms/functions.php 1 location

@@ 844-849 (lines=6) @@
841
842
	$amount = 0.00;
843
844
	foreach ( $prices as $price ) {
845
		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
846
			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
847
			break;
848
		};
849
	}
850
851
	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
852
}