Give_Payment::get_fees PHP Method

get_fees() public method

Get the fees, filterable by type
Since: 1.5
public get_fees ( string $type = 'all' ) : array
$type string All, item, fee
return array The Fees for the type specified
    public function get_fees($type = 'all')
    {
        $fees = array();
        if (!empty($this->fees) && is_array($this->fees)) {
            foreach ($this->fees as $fee_id => $fee) {
                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
                    continue;
                }
                $fee['id'] = $fee_id;
                $fees[] = $fee;
            }
        }
        return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
    }

Usage Example

Beispiel #1
0
/**
 * Retrieves arbitrary fees for the payment
 *
 * @since 1.5
 *
 * @param int    $payment_id Payment ID
 * @param string $type       Fee type
 *
 * @return mixed array if payment fees found, false otherwise
 */
function give_get_payment_fees($payment_id = 0, $type = 'all')
{
    $payment = new Give_Payment($payment_id);
    return $payment->get_fees($type);
}