vae_store_create_coupon_code()

The vae_store_create_coupon_code() function creates a coupon code.

Usage

vae_store_create_coupon_code($options)

  • $options - PHP associative array containing the options for the coupon code.

    Valid keys are: code, country, custom, description, discount_shipping, excluded_classes, fixed_amount, free_shipping, free_shipping_method, included_classes, manually_approve_orders, max_per_customer, min_order_amount, min_order_items, number_available, percentage_amount, required_classes, start_at, stop_at, voucher. These correspond with the options described on the page for creating coupon codes.

    All keys are optional except code, which is required.

Returns

Returns false on failure, or true on success.

Sample Usage

<?php
// Create coupon code
$return_value = vae_store_create_coupon_code(array(
  'code' => $voucher_code, 
  'description' => "$" . $amount . " Voucher, " . $order['billing_name'], 
  'number_available' => 1, 
  'fixed_amount' => $amount
)); 
if ($return_value == false) {
  echo "FAILURE";
} else {
  echo "SUCCESS";
}
?>