Give_Donate_Form::decrease_earnings PHP Method

decrease_earnings() public method

Decrease the earnings by the given amount
Since: 1.0
public decrease_earnings ( integer $amount ) : float | false
$amount integer Amount of donation.
return float | false
    public function decrease_earnings($amount)
    {
        $earnings = give_get_form_earnings_stats($this->ID);
        if ($earnings > 0) {
            // Only decrease if greater than zero
            $new_amount = $earnings - (double) $amount;
            if ($this->update_meta('_give_form_earnings', $new_amount)) {
                $this->earnings = $new_amount;
                return $this->earnings;
            }
        }
        return false;
    }

Usage Example

Ejemplo n.º 1
0
/**
 * Decreases the total earnings of a form. Primarily for when a purchase is refunded.
 *
 * @since 1.0
 *
 * @param int $give_form_id Give Form ID
 * @param int $amount       Earnings
 *
 * @return bool|int
 */
function give_decrease_earnings($give_form_id = 0, $amount)
{
    $form = new Give_Donate_Form($give_form_id);
    return $form->decrease_earnings($amount);
}
All Usage Examples Of Give_Donate_Form::decrease_earnings