Give_Donate_Form::decrease_sales PHP Method

decrease_sales() public method

Decrement the sale count by one
Since: 1.0
public decrease_sales ( integer $quantity = 1 ) : integer | false
$quantity integer The quantity to decrease by. Default is 1.
return integer | false New number of total sales.
    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;
    }

Usage Example

Exemplo n.º 1
0
/**
 * 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();
}
All Usage Examples Of Give_Donate_Form::decrease_sales