public function decrease_sales($quantity = 1) { $sales = give_get_form_sales_stats($this->ID); // Only decrease if not already zero if ($sales > 0) { $quantity = absint($quantity); $total_sales = $sales - $quantity; if ($this->update_meta('_give_form_sales', $total_sales)) { $this->sales = $sales; return $sales; } } return false; }
/** * Decreases the sale count of a form. Primarily for when a donation is refunded. * * @since 1.0 * * @param int $give_form_id Give Form ID * * @return bool|int */ function give_decrease_purchase_count($give_form_id = 0) { $form = new Give_Donate_Form($give_form_id); return $form->decrease_sales(); }