本文整理汇总了PHP中edd_get_lowest_price_option函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_lowest_price_option函数的具体用法?PHP edd_get_lowest_price_option怎么用?PHP edd_get_lowest_price_option使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_lowest_price_option函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_wallet_item_incentive_amount
/**
* Maybe add incentive discounts
*
* @since 1.0.1
* @param float $discount The current discount amount
* @param array $item The cart item array
* @return float $discount The updated discount amount
*/
function edd_wallet_item_incentive_amount($discount, $item)
{
$incentive_amount = edd_get_option('edd_wallet_incentive_amount', 0);
if ($incentive_amount <= 0) {
return $discount;
}
if (!EDD()->session->get('wallet_has_incentives')) {
return $discount;
}
if (edd_has_variable_prices($item['id'])) {
$prices = edd_get_variable_prices($item['id']);
$price_id = isset($item['options']['price_id']) ? $item['options']['price_id'] : 0;
if ($price_id !== false && $price_id !== '' && isset($prices[$price_id])) {
$price = edd_get_price_option_amount($item['id'], $price_id);
} else {
$price = edd_get_lowest_price_option($item['id']);
}
} else {
$price = edd_get_download_price($item['id']);
}
$incentive_type = edd_get_option('edd_wallet_incentive_type', 'flatrate');
if ($incentive_type == 'percent') {
$incentive_amount /= 100;
$incentive_amount = $price * $incentive_amount;
if (edd_item_quantities_enabled() && edd_get_option('edd_wallet_incentive_quantities', false)) {
$incentive_amount *= $item['quantity'];
}
$incentive_amount = number_format($incentive_amount, 2, '.', '');
} else {
if (edd_item_quantities_enabled() && edd_get_option('edd_wallet_incentive_quantities', false)) {
$incentive_amount *= $item['quantity'];
}
}
$discount += $incentive_amount;
return $discount;
}
示例2: edd_points_get_earning_points
/**
* 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;
}
示例3: edd_price_range
/**
* 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);
}
示例4: edd_download_meta_box_save
/**
* Save post meta when the save_post action is called
*
* @since 1.0
* @param int $post_id Download (Post) ID
* @global array $post All the data of the the current post
* @return void
*/
function edd_download_meta_box_save($post_id, $post)
{
if (!isset($_POST['edd_download_meta_box_nonce']) || !wp_verify_nonce($_POST['edd_download_meta_box_nonce'], basename(__FILE__))) {
return;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['bulk_edit'])) {
return;
}
if (isset($post->post_type) && 'revision' == $post->post_type) {
return;
}
if (!current_user_can('edit_product', $post_id)) {
return;
}
// The default fields that get saved
$fields = edd_download_metabox_fields();
foreach ($fields as $field) {
// Accept blank or "0"
if ('_edd_download_limit' == $field) {
if (!empty($_POST[$field]) || strlen($_POST[$field]) === 0 || "0" === $_POST[$field]) {
$global_limit = edd_get_option('file_download_limit');
$new_limit = apply_filters('edd_metabox_save_' . $field, $_POST[$field]);
// Only update the new limit if it is not the same as the global limit
if ($global_limit == $new_limit) {
delete_post_meta($post_id, '_edd_download_limit');
} else {
update_post_meta($post_id, '_edd_download_limit', $new_limit);
}
}
} elseif ('_edd_default_price_id' == $field && edd_has_variable_prices($post_id)) {
$new_default_price_id = !empty($_POST[$field]) && is_numeric($_POST[$field]) ? (int) $_POST[$field] : 1;
update_post_meta($post_id, $field, $new_default_price_id);
} else {
if (!empty($_POST[$field])) {
$new = apply_filters('edd_metabox_save_' . $field, $_POST[$field]);
update_post_meta($post_id, $field, $new);
} else {
delete_post_meta($post_id, $field);
}
}
}
if (edd_has_variable_prices($post_id)) {
$lowest = edd_get_lowest_price_option($post_id);
update_post_meta($post_id, 'edd_price', $lowest);
}
do_action('edd_save_download', $post_id, $post);
}
示例5: is_free
/**
* 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);
}
示例6: add_download
/**
* Add a download to a given payment
*
* @since 2.5
* @param int $download_id The download to add
* @param int $args Other arguments to pass to the function
* @return void
*/
public function add_download($download_id = 0, $args = array(), $options = array())
{
$download = new EDD_Download($download_id);
// Bail if this post isn't a download
if (!$download || $download->post_type !== 'download') {
return false;
}
// Set some defaults
$defaults = array('quantity' => 1, 'price_id' => false, 'item_price' => 0.0, 'discount' => 0, 'tax' => 0.0, 'fees' => array());
$args = wp_parse_args(apply_filters('edd_payment_add_download_args', $args, $download->ID), $defaults);
// Allow overriding the price
if ($args['item_price']) {
$item_price = $args['item_price'];
} else {
// Deal with variable pricing
if (edd_has_variable_prices($download->ID)) {
$prices = get_post_meta($download->ID, 'edd_variable_prices', true);
if ($args['price_id'] && array_key_exists($args['price_id'], (array) $prices)) {
$item_price = $prices[$args['price_id']]['amount'];
} else {
$item_price = edd_get_lowest_price_option($download->ID);
$args['price_id'] = edd_get_lowest_price_id($download->ID);
}
} else {
$item_price = edd_get_download_price($download->ID);
}
}
// Sanitizing the price here so we don't have a dozen calls later
$item_price = edd_sanitize_amount($item_price);
$quantity = edd_item_quantities_enabled() ? absint($args['quantity']) : 1;
$amount = round($item_price * $quantity, edd_currency_decimal_filter());
if (!empty($args['fees'])) {
foreach ($args['fees'] as $key => $fee) {
if (empty($fee['download_id'])) {
$args['fees'][$key]['download_id'] = $download_id;
}
$this->add_fee($args['fees'][$key], false);
}
}
// Setup the downloads meta item
$new_download = array('id' => $download->ID, 'quantity' => $quantity, 'fees' => $args['fees']);
$default_options = array('quantity' => $quantity);
if (!empty($args['price_id'])) {
$default_options['price_id'] = (int) $args['price_id'];
}
$options = wp_parse_args($options, $default_options);
$new_download['options'] = $options;
$this->downloads[] = $new_download;
$discount = $args['discount'];
$subtotal = $amount;
$tax = $args['tax'];
if (edd_prices_include_tax()) {
$subtotal -= round($tax, edd_currency_decimal_filter());
}
$total = $subtotal - $discount + $tax;
// Do not allow totals to go negatve
if ($total < 0) {
$total = 0;
}
// Silly item_number array
$item_number = array('id' => $download->ID, 'quantity' => $quantity, 'options' => $options);
$this->cart_details[] = array('name' => $download->post_title, 'id' => $download->ID, 'item_number' => $item_number, 'item_price' => round($item_price, edd_currency_decimal_filter()), 'quantity' => $quantity, 'discount' => $discount, 'subtotal' => round($subtotal, edd_currency_decimal_filter()), 'tax' => round($tax, edd_currency_decimal_filter()), 'fees' => $args['fees'], 'price' => round($total, edd_currency_decimal_filter()));
$added_download = end($this->cart_details);
$added_download['action'] = 'add';
$this->pending['downloads'][] = $added_download;
reset($this->cart_details);
$this->increase_subtotal($subtotal - $discount);
$this->increase_tax($tax);
return true;
}
示例7: edd_sl_get_license_upgrade_cost
/**
* Retrieve the cost to upgrade a license
*
* @since 3.3
* @return float
*/
function edd_sl_get_license_upgrade_cost($license_id = 0, $upgrade_id = 0)
{
$url = home_url();
$download_id = edd_software_licensing()->get_download_id($license_id);
$upgrades = edd_sl_get_upgrade_paths($download_id);
if (edd_has_variable_prices($download_id)) {
$price_id = edd_software_licensing()->get_price_id($license_id);
if (false !== $price_id && '' !== $price_id) {
$old_price = edd_get_price_option_amount($download_id, $price_id);
} else {
$old_price = edd_get_lowest_price_option($download_id);
}
} else {
$old_price = edd_get_download_price($download_id);
}
if (isset($upgrades[$upgrade_id]['price_id']) && false !== $upgrades[$upgrade_id]['price_id']) {
$new_price = edd_get_price_option_amount($upgrades[$upgrade_id]['download_id'], $upgrades[$upgrade_id]['price_id']);
} else {
$new_price = edd_get_download_price($upgrades[$upgrade_id]['download_id']);
}
$cost = $new_price;
if (!empty($upgrades[$upgrade_id]['pro_rated'])) {
$cost -= $old_price;
}
if (isset($upgrades[$upgrade_id]['discount'])) {
$cost -= $upgrades[$upgrade_id]['discount'];
}
if ($cost < 0) {
$cost = 0;
}
return apply_filters('edd_sl_license_upgrade_cost', $cost, $license_id, $upgrade_id);
}
示例8: checkout_edd_price_range
/**
* 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);
}
示例9: edd_sl_get_renewal_discount_amount
/**
* @since 3.4
* @param $item array the cart item array
* @return float
*/
function edd_sl_get_renewal_discount_amount($item = array(), $license_key = '')
{
$discount = 0.0;
$license_id = edd_software_licensing()->get_license_by_key($license_key);
if (edd_has_variable_prices($item['id'])) {
$price_id = isset($options['price_id']) ? $options['price_id'] : (int) edd_software_licensing()->get_price_id($license_id);
$prices = edd_get_variable_prices($item['id']);
if (false !== $price_id && '' !== $price_id && isset($prices[$price_id])) {
$price = edd_get_price_option_amount($item['id'], $price_id);
} else {
$price = edd_get_lowest_price_option($item['id']);
}
} else {
$price = edd_get_download_price($item['id']);
}
$renewal_discount_percentage = edd_sl_get_renewal_discount_percentage($license_id);
if ($renewal_discount_percentage) {
$renewal_discount = $price * ($renewal_discount_percentage / 100);
// todo: fix this. number_format returns a string. we should not perform math on strings.
$renewal_discount = number_format($renewal_discount, 2, '.', '');
$discount += $renewal_discount;
}
return apply_filters('edd_sl_get_renewal_discount_amount', $discount, $license_key, $item);
}