Exemple #1
0
/**
 * Undo Purchase
 *
 * Undoes a donation, including the decrease of donations and earning stats.
 * Used for when refunding or deleting a donation.
 *
 * @since  1.0
 *
 * @param  int $form_id    Form ID (default: false)
 * @param  int $payment_id Payment ID
 *
 * @return void
 */
function give_undo_purchase($form_id = false, $payment_id)
{
    if (!empty($form_id)) {
        $form_id = false;
        _give_deprected_argument('form_id', 'give_undo_purchase', '1.5');
    }
    $payment = new Give_Payment($payment_id);
    $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
    if (true === $maybe_decrease_earnings) {
        // decrease earnings
        give_decrease_earnings($payment->form_id, $payment->total);
    }
    $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id);
    if (true === $maybe_decrease_sales) {
        // decrease purchase count
        give_decrease_purchase_count($payment->form_id);
    }
}
Exemple #2
0
/**
 * Undoes a donation, including the decrease of donations and earning stats. Used for when refunding or deleting a donation
 *
 * @since 1.0
 *
 * @param int $form_id    Form (Post) ID
 * @param int $payment_id Payment ID
 *
 * @return void
 */
function give_undo_purchase($form_id, $payment_id)
{
    if (give_is_test_mode()) {
        return;
    }
    $amount = give_get_payment_amount($payment_id);
    // decrease earnings
    give_decrease_earnings($form_id, $amount);
    // decrease purchase count
    give_decrease_purchase_count($form_id);
}