/**
  * Process Get Discounts API Request
  *
  * @access public
  * @since 1.6
  * @global object $wpdb Used to query the database using the WordPress
  *   Database API
  * @param int $discount Discount ID
  * @return array $discounts Multidimensional array of the discounts
  */
 public function get_discounts($discount = null)
 {
     $discount_list = array();
     if (!user_can($this->user_id, 'manage_shop_discounts') && !$this->override) {
         return $discount_list;
     }
     $error = array();
     if (empty($discount)) {
         global $wpdb;
         $paged = $this->get_paged();
         $per_page = $this->per_page();
         $discounts = edd_get_discounts(array('posts_per_page' => $per_page, 'paged' => $paged));
         $count = 0;
         if (empty($discounts)) {
             $error['error'] = __('No discounts found!', 'easy-digital-downloads');
             return $error;
         }
         foreach ($discounts as $discount) {
             $discount_list['discounts'][$count]['ID'] = $discount->ID;
             $discount_list['discounts'][$count]['name'] = $discount->post_title;
             $discount_list['discounts'][$count]['code'] = edd_get_discount_code($discount->ID);
             $discount_list['discounts'][$count]['amount'] = edd_get_discount_amount($discount->ID);
             $discount_list['discounts'][$count]['min_price'] = edd_get_discount_min_price($discount->ID);
             $discount_list['discounts'][$count]['type'] = edd_get_discount_type($discount->ID);
             $discount_list['discounts'][$count]['uses'] = edd_get_discount_uses($discount->ID);
             $discount_list['discounts'][$count]['max_uses'] = edd_get_discount_max_uses($discount->ID);
             $discount_list['discounts'][$count]['start_date'] = edd_get_discount_start_date($discount->ID);
             $discount_list['discounts'][$count]['exp_date'] = edd_get_discount_expiration($discount->ID);
             $discount_list['discounts'][$count]['status'] = $discount->post_status;
             $discount_list['discounts'][$count]['product_requirements'] = edd_get_discount_product_reqs($discount->ID);
             $discount_list['discounts'][$count]['requirement_condition'] = edd_get_discount_product_condition($discount->ID);
             $discount_list['discounts'][$count]['global_discount'] = edd_is_discount_not_global($discount->ID);
             $discount_list['discounts'][$count]['single_use'] = edd_discount_is_single_use($discount->ID);
             $count++;
         }
     } else {
         if (is_numeric($discount) && get_post($discount)) {
             $discount_list['discounts'][0]['ID'] = $discount;
             $discount_list['discounts'][0]['name'] = get_post_field('post_title', $discount);
             $discount_list['discounts'][0]['code'] = edd_get_discount_code($discount);
             $discount_list['discounts'][0]['amount'] = edd_get_discount_amount($discount);
             $discount_list['discounts'][0]['min_price'] = edd_get_discount_min_price($discount);
             $discount_list['discounts'][0]['type'] = edd_get_discount_type($discount);
             $discount_list['discounts'][0]['uses'] = edd_get_discount_uses($discount);
             $discount_list['discounts'][0]['max_uses'] = edd_get_discount_max_uses($discount);
             $discount_list['discounts'][0]['start_date'] = edd_get_discount_start_date($discount);
             $discount_list['discounts'][0]['exp_date'] = edd_get_discount_expiration($discount);
             $discount_list['discounts'][0]['status'] = get_post_field('post_status', $discount);
             $discount_list['discounts'][0]['product_requirements'] = edd_get_discount_product_reqs($discount);
             $discount_list['discounts'][0]['requirement_condition'] = edd_get_discount_product_condition($discount);
             $discount_list['discounts'][0]['global_discount'] = edd_is_discount_not_global($discount);
             $discount_list['discounts'][0]['single_use'] = edd_discount_is_single_use($discount);
         } else {
             $error['error'] = sprintf(__('Discount %s not found!', 'easy-digital-downloads'), $discount);
             return $error;
         }
     }
     return $discount_list;
 }
</p>
				</td>
			</tr>
			<?php 
do_action('edd_edit_discount_form_before_min_cart_amount', $discount_id, $discount);
?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-min-cart-amount"><?php 
_e('Minimum Amount', 'edd');
?>
</label>
				</th>
				<td>
					<input type="text" id="edd-min-cart-amount" name="min_price" value="<?php 
echo esc_attr(edd_get_discount_min_price($discount_id));
?>
" style="width: 40px;"/>
					<p class="description"><?php 
_e('The minimum amount that must be purchased before this discount can be used. Leave blank for no minimum.', 'edd');
?>
</p>
				</td>
			</tr>
			<?php 
do_action('edd_edit_discount_form_before_status', $discount_id, $discount);
?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-status"><?php 
_e('Status', 'edd');
/**
 * Is Cart Minimum Met
 *
 * Checks to see if the minimum purchase amount has been met
 *
 * @since 1.1.7
 * @param int $code_id Discount ID
 * @return bool $return
 */
function edd_discount_is_min_met($code_id = null)
{
    $discount = edd_get_discount($code_id);
    $return = false;
    if ($discount) {
        $min = edd_get_discount_min_price($code_id);
        $cart_amount = edd_get_cart_subtotal();
        if ((double) $cart_amount >= (double) $min) {
            // Minimum has been met
            $return = true;
        } else {
            edd_set_error('edd-discount-error', sprintf(__('Minimum order of %s not met.', 'edd'), edd_currency_filter(edd_format_amount($min))));
        }
    }
    return apply_filters('edd_is_discount_min_met', $return, $code_id);
}
/**
 * Is Cart Minimum Met
 *
 * Checks to see if the minimum purchase amount has been met
 *
 * @param int $code_id
 *
 * @access      public
 * @since       1.1.7
 * @return      bool
 */
function edd_discount_is_min_met($code_id = null)
{
    $discount = edd_get_discount($code_id);
    $return = false;
    if ($discount) {
        $min = edd_get_discount_min_price($code_id);
        $cart_amount = edd_get_cart_amount();
        if ((double) $cart_amount >= (double) $min) {
            // minimum has been met
            $return = true;
        }
    }
    return apply_filters('edd_is_discount_min_met', $return, $code_id);
}