/** * Get Downloads Earning Points * * Handles to return earning points for download * * @package Easy Digital Downloads - Points and Rewards * @since 1.0.0 **/ public function edd_points_get_earning_points($downloadid, $priceoptions = array(), $checkout = false) { //if this function called from checkout page then use third parameter to TRUE global $edd_options; $earningpointsbyuser = 0; //check if price is for checkout page if (!empty($checkout)) { //if checkout page $edd_price = edd_get_cart_item_price($downloadid, $priceoptions); } else { //if not is checkout page if (edd_has_variable_prices($downloadid)) { //check product price is varible pricing enable or not //$prices = edd_get_variable_prices( $downloadid ); //$edd_price = edd_sanitize_amount( $prices[0]['amount'] ); $edd_price[0] = edd_get_lowest_price_option($downloadid); $edd_price[1] = edd_get_highest_price_option($downloadid); } else { //get download price $edd_price = edd_get_download_price($downloadid); } //end else } //end else //get download points for download level from meta box $downloadearnpoints = $this->edd_points_get_download_earn_points($downloadid); if (is_numeric($downloadearnpoints)) { return $downloadearnpoints; } //check if points of download are set in category level $downloadearnpoints = $this->edd_points_get_category_earn_points($downloadid); if (is_numeric($downloadearnpoints)) { return $downloadearnpoints; } if (is_array($edd_price)) { // if product is variable then edd_price contains array of lowest and highest price $earning_points_by_user = array(); foreach ($edd_price as $key => $data) { $earning_points_by_user[$key] = $this->edd_points_calculate_earn_points_from_price($data); } return $earning_points_by_user; } else { // if product is simple product //calculate the earn points from price $earningpointsbyuser = $this->edd_points_calculate_earn_points_from_price($edd_price); } // get download points based on global setting return $earningpointsbyuser; }
/** * Determine if the download is free or if the given price ID is free * * @since 2.2 * @return bool */ public function is_free($price_id = false) { $is_free = false; $variable_pricing = edd_has_variable_prices($this->ID); if ($variable_pricing && !is_null($price_id) && $price_id !== false) { $price = edd_get_price_option_amount($this->ID, $price_id); } elseif ($variable_pricing && $price_id === false) { $lowest_price = (double) edd_get_lowest_price_option($this->ID); $highest_price = (double) edd_get_highest_price_option($this->ID); if ($lowest_price === 0.0 && $highest_price === 0.0) { $price = 0; } } elseif (!$variable_pricing) { $price = get_post_meta($this->ID, 'edd_price', true); } if (isset($price) && (double) $price == 0) { $is_free = true; } return (bool) apply_filters('edd_is_free_download', $is_free, $this->ID, $price_id); }
/** * Retrieves a price from from low to high of a variable priced download * * @since 1.4.4 * @param int $download_id ID of the download * @return string $range A fully formatted price range */ function edd_price_range($download_id = 0) { $low = edd_get_lowest_price_option($download_id); $high = edd_get_highest_price_option($download_id); $range = '<span class="edd_price_range_low">' . edd_currency_filter(edd_format_amount($low)) . '</span>'; $range .= '<span class="edd_price_range_sep"> – </span>'; $range .= '<span class="edd_price_range_high">' . edd_currency_filter(edd_format_amount($high)) . '</span>'; return apply_filters('edd_price_range', $range, $download_id, $low, $high); }
/** * Custom pricing range output * * @since 1.0 */ function checkout_edd_price_range($download_id = 0) { $low = edd_get_lowest_price_option($download_id); $high = edd_get_highest_price_option($download_id); $range = '<span class="edd_price">' . edd_currency_filter(edd_format_amount($low)); $range .= ' – '; $range .= edd_currency_filter(edd_format_amount($high)) . '</span>'; return apply_filters('edd_price_range', $range, $download_id, $low, $high); }