You appear to be a bot. Output may be restricted
Description
Retrieve all active fees
Usage
$array|bool = EDD_Fees::get_fees( $type, $download_id, $price_id );
Parameters
- $type
- ( string ) optional default: fee – Fee type, "fee" or "item"
- $download_id
- ( int ) optional – The download ID whose fees to retrieve
- $price_id
- ( int ) optional – The variable price ID whose fees to retrieve
Returns
array|bool List of fees when available, false when there are no fees
Source
File name: easy-digital-downloads/includes/class-edd-fees.php
Lines:
1 to 66 of 66
public function get_fees( $type = 'fee', $download_id = 0, $price_id = NULL ) { $fees = EDD()->session->get( 'edd_cart_fees' ); if ( EDD()->cart->is_empty() ) { // We can only get item type fees when the cart is empty $type = 'item'; } if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { foreach ( $fees as $key => $fee ) { if ( ! empty( $fee['type'] ) && $type != $fee['type'] ) { unset( $fees[ $key ] ); } } } if ( ! empty( $fees ) && ! empty( $download_id ) ) { // Remove fees that don't belong to the specified Download $applied_fees = array(); foreach ( $fees as $key => $fee ) { if ( empty( $fee['download_id'] ) || (int) $download_id !== (int) $fee['download_id'] ) { unset( $fees[ $key ] ); } $fee_hash = md5( $fee['amount'] . $fee['label'] . $fee['type'] ); if ( in_array( $fee_hash, $applied_fees ) ) { unset( $fees[ $key ] ); } $applied_fees[] = $fee_hash; } } // Now that we've removed any fees that are for other Downloads, lets also remove any fees that don't match this price id if ( ! empty( $fees ) && ! empty( $download_id ) && ! is_null( $price_id ) ) { // Remove fees that don't belong to the specified Download AND Price ID foreach ( $fees as $key => $fee ) { if ( is_null( $fee['price_id'] ) ) { continue; } if ( (int) $price_id !== (int) $fee['price_id'] ){ unset( $fees[ $key ] ); } } } if ( ! empty( $fees ) ) { // Remove fees that belong to a specific download but are not in the cart foreach ( $fees as $key => $fee ) { if ( empty( $fee['download_id'] ) ) { continue; } if ( ! edd_item_in_cart( $fee['download_id'] ) ) { unset( $fees[ $key ] ); } } } // Allow 3rd parties to process the fees before returning them return apply_filters( 'edd_fees_get_fees', ! empty( $fees ) ? $fees : array(), $this ); }