vae_store_discount_code()

The vae_store_discount_code() retrieves information about the currently applied discount code. When called with an argument, it sets the currently applied discount code.

Usage – Retrieve Current Discount Code

vae_store_discount_code()

Returns

Returns an associative array containing the information about the currently applied discount code.

The array keys will include: code, description, fixed_amount, percentage_amount, free_shipping, min_order_amount, min_order_items, discount_shipping, number_available, start_at, stop_at, max_per_customer. These correspond with the options described on the page for creating coupon codes.

Sample Usage

<?php
// Display message if using a really good discount code
$code = vae_store_discount_code();
if ($code['percentage_amount'] > 50) {
  echo "Wow, you're getting a great deal.";
}
?>

Usage – Apply a Discount Code

vae_store_discount_code($code, $force = false)

  • $code - discount code to apply.

  • $force - set to true to force application of the code even if there is already a discount code set. If false, the presence of an existing discount code will halt this function.

Returns

Returns false on failure, or true on success.

Sample Usage

<?php
// Apply discount code 'WELCOME'
$return_value = vae_store_discount_code("WELCOME");
if ($return_value == false) {
  echo "FAILURE";
} else {
  echo "SUCCESS";
}
?>