/**
 * Price
 *
 * Displays a formatted price for a download.
 *
 * @access      public
 * @since       1.0
 * @param       int $download_id the ID of the download price to show
 * @param		bool whether to echo or return the results
* @return       void
*/
function edd_price($download_id, $echo = true)
{
    if (edd_has_variable_prices($download_id)) {
        $prices = edd_get_variable_prices($download_id);
        // return the lowest price
        $price_float = 0;
        foreach ($prices as $key => $value) {
            if ((double) $prices[$key]['amount'] < $price_float or $price_float == 0) {
                $price_float = (double) $prices[$key]['amount'];
            }
        }
        $price = edd_sanitize_amount($price_float);
    } else {
        $price = edd_get_download_price($download_id);
    }
    if (edd_use_taxes() && edd_taxes_on_prices()) {
        $price += edd_calculate_tax($price);
    }
    $price = apply_filters('edd_download_price', $price, $download_id);
    $price = '<span class="edd_price" id="edd_price_' . $download_id . '">' . $price . '</span>';
    if ($echo) {
        echo $price;
    } else {
        return $price;
    }
}
/**
 * Get final price of a download after discount
 * 
 * Modified From:
 * includes/download-functions.php -> edd_price()
 * Modified Parts:
 * Remove the price as a number, without the html formatting.
 * 
 * @param  int   $download_id ID of the download
 * @return float              Download price
 */
function vp_edd_fd_get_calculated_price($download_id)
{
    if (edd_has_variable_prices($download_id)) {
        $prices = edd_get_variable_prices($download_id);
        // Return the lowest price
        $price_float = 0;
        foreach ($prices as $key => $value) {
            if ((double) $prices[$key]['amount'] < $price_float or $price_float == 0) {
                $price_float = (double) $prices[$key]['amount'];
            }
        }
        $price = edd_sanitize_amount($price_float);
    } else {
        $price = edd_get_download_price($download_id);
    }
    if (edd_use_taxes() && edd_taxes_on_prices()) {
        $price += edd_calculate_tax($price);
    }
    return $price;
}
/**
 * Get Cart Item Template
 *
 * @access      public
 * @since       1.0
 * @return      string
*/
function edd_get_cart_item_template($cart_key, $item, $ajax = false)
{
    global $post;
    $id = is_array($item) ? $item['id'] : $item;
    $remove_url = edd_remove_item_url($cart_key, $post, $ajax);
    $title = get_the_title($id);
    $options = !empty($item['options']) ? $item['options'] : array();
    $price = edd_get_cart_item_price($id, $options);
    if (edd_use_taxes() && edd_taxes_on_prices()) {
        $price += edd_calculate_tax($price);
    }
    if (!empty($options)) {
        $title .= ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']);
    }
    $remove = '<a href="' . esc_url($remove_url) . '" data-cart-item="' . absint($cart_key) . '" data-download-id="' . absint($id) . '" data-action="edd_remove_from_cart" class="edd-remove-from-cart">' . __('remove', 'edd') . '</a>';
    $item = '<li class="edd-cart-item"><span class="edd-cart-item-title">' . $title . '</span>&nbsp;';
    $item .= '<span class="edd-cart-item-separator">-</span>&nbsp;' . edd_currency_filter(edd_format_amount($price)) . '&nbsp;';
    $item .= '<span class="edd-cart-item-separator">-</span> ' . $remove . '</li>';
    return apply_filters('edd_cart_item', $item, $id);
}
/**
 * Get cart tax on Fees
 *
 * @since 2.0
 * @uses EDD()->fees->get_fees()
 * @return float Total Cart tax on Fees
 */
function edd_get_cart_fee_tax()
{
    $tax = 0;
    $fees = edd_get_cart_fees();
    if ($fees) {
        foreach ($fees as $fee_id => $fee) {
            if (!empty($fee['no_tax'])) {
                continue;
            }
            // Fees must (at this time) be exclusive of tax
            add_filter('edd_prices_include_tax', '__return_false');
            $tax += edd_calculate_tax($fee['amount']);
            remove_filter('edd_prices_include_tax', '__return_false');
        }
    }
    return apply_filters('edd_get_cart_fee_tax', $tax);
}
示例#5
0
/**
 * Contribute now list options
 * @return void
**/
function wpo_campaign_contribute_options_custom($prices, $type, $download_id)
{
    $campaign = atcf_get_campaign($download_id);
    $uid = wpo_makeid();
    ?>
	<div class="edd_price_options <?php 
    echo $campaign->is_active() ? 'active' : 'expired';
    ?>
" <?php 
    echo $campaign->is_donations_only() ? 'style="display: none"' : null;
    ?>
>
		<ul>
			<?php 
    foreach ($prices as $key => $price) {
        ?>
				<?php 
        $amount = $price['amount'];
        $limit = isset($price['limit']) ? $price['limit'] : '';
        $bought = isset($price['bought']) ? $price['bought'] : 0;
        $allgone = false;
        if ($bought == absint($limit) && '' != $limit) {
            $allgone = true;
        }
        if (edd_use_taxes() && edd_taxes_on_prices()) {
            $amount += edd_calculate_tax($amount);
        }
        ?>
				<li class="atcf-price-option pledge-level <?php 
        echo $allgone ? 'inactive' : null;
        ?>
"  data-pri="<?php 
        echo edd_sanitize_amount($amount);
        ?>
"  data-price="<?php 
        echo edd_sanitize_amount($amount);
        ?>
-<?php 
        echo esc_attr($key);
        ?>
">
					<div class="clear">
						<h3><label><!-- <label for="<?php 
        echo esc_attr('edd_price_option_' . $download_id . '_' . $key);
        ?>
"> -->
							<?php 
        if ($campaign->is_active()) {
            if (!$allgone) {
                printf('<input type="radio" name="edd_options[price_id][]" id="%1$s" class="%2$s edd_price_options_input" value="%3$s"/>', esc_attr('edd_price_option_' . $download_id . '_' . $key . '_' . $uid), esc_attr('edd_price_option_' . $download_id), esc_attr($key));
            }
        }
        ?>
  
							<?php 
        echo edd_currency_filter(edd_format_amount($amount));
        ?>
						</label></h3>
						
						<div class="backers hidden">
							<div class="backer-count">
								<i class="icon-user"></i> <?php 
        printf(_n('1 Backer', '%1$s Backers', $bought, 'atcf'), $bought);
        ?>
							</div>
							<?php 
        if ('' != $limit && !$allgone) {
            ?>
								<small class="limit"><?php 
            printf(__('Limit of %d &mdash; %d remaining', 'atcf'), $limit, $limit - $bought);
            ?>
</small>
							<?php 
        } elseif ($allgone) {
            ?>
								<small class="gone"><?php 
            _e('All gone!', 'atcf');
            ?>
</small>
							<?php 
        }
        ?>
						</div>

					</div>
					<?php 
        //echo wpautop( wp_kses_data( $price[ 'name' ] ) );
        ?>
				</li>

			<?php 
    }
    ?>
			<li class="price-custom">
				<div class="campaign-price-input">
					<div class="price-wrapper"><span class="title"><?php 
    _e('Amount: ', TEXTDOMAIN);
    ?>
</span><input type="text" name="atcf_custom_price" value="" /></div>
				</div>	
			</li>

		</ul>
	</div><!--end .edd_price_options-->
<?php 
}
/**
 * Gets the total tax amount for the cart contents
 *
 * @access      public
 * @since       1.2.3
 * @return      string
*/
function edd_get_cart_tax()
{
    if (!edd_use_taxes()) {
        return 0;
    }
    $cart_sub_total = edd_get_cart_subtotal();
    $cart_tax = edd_calculate_tax($cart_sub_total);
    $cart_tax = number_format($cart_tax, 2);
    return apply_filters('edd_get_cart_tax', $cart_tax, $cart_sub_total);
}
/**
 * Variable price output
 *
 * To override this output, remove this action, then add
 * your own via a theme, child theme, or plugin.
 *
 * @access      public
 * @since       1.2.3
 * @return      void
 */
function edd_purchase_variable_pricing($download_id)
{
    $variable_pricing = edd_has_variable_prices($download_id);
    if (!$variable_pricing) {
        return;
    }
    $prices = edd_get_variable_prices($download_id);
    do_action('edd_before_price_options', $download_id);
    ?>
	<div class="edd_price_options">
		<ul>
			<?php 
    if ($prices) {
        foreach ($prices as $key => $price) {
            $amount = $price['amount'];
            if (edd_use_taxes() && edd_taxes_on_prices()) {
                $amount += edd_calculate_tax($price['amount']);
            }
            printf('<li><label for="%2$s"><input type="radio" %1$s name="edd_options[price_id]" id="%2$s" class="%3$s" value="%4$s"/> %5$s</label></li>', checked(0, $key, false), esc_attr('edd_price_option_' . $download_id . '_' . $key), esc_attr('edd_price_option_' . $download_id), esc_attr($key), esc_html($price['name'] . ' - ' . edd_currency_filter(edd_format_amount($amount))));
        }
    }
    ?>
		</ul>
	</div><!--end .edd_price_options-->
<?php 
    add_action('edd_after_price_options', $download_id);
}
/**
 * Retrieve the Cart Content Details
 *
 * @since 1.0
 * @return array $defailt Cart content details
 */
function edd_get_cart_content_details()
{
    $cart_items = edd_get_cart_contents();
    if (empty($cart_items)) {
        return false;
    }
    $details = array();
    $is_taxed = edd_is_cart_taxed();
    foreach ($cart_items as $key => $item) {
        $price = edd_get_cart_item_price($item['id'], $item['options']);
        $non_taxed_price = edd_get_cart_item_price($item['id'], $item['options'], false);
        $details[$key] = array('name' => get_the_title($item['id']), 'id' => $item['id'], 'item_number' => $item, 'price' => $price, 'quantity' => 1, 'tax' => $is_taxed ? edd_calculate_tax($non_taxed_price, false) : 0);
    }
    return $details;
}
示例#9
0
        foreach ($price as $row => $value) {
            if (is_object($post) && ($post->post_content == '[purchase_history]' || $post->post_content == '[downloads_history]') && $payment_id > 0) {
                if (isset($edd_options['expired'][$payment_id]) && $edd_options['expired'][$payment_id] == $download_id) {
                    if (!isset($value['renew'])) {
                        unset($price[$row]);
                    }
                }
            } else {
                if (isset($value['renew'])) {
                    unset($price[$row]);
                }
            }
        }
    }
    return $price;
}
//add_action( 'edd_purchase_variable_prices', 'edd_plans_filter_download_price', 900, 2 );
add_filter('edd_get_download_price', 'edd_plans_filter_download_price', 11, 2);
add_filter('edd_get_variable_prices', 'edd_plans_filter_download_price', 11, 2);
function edd_plans_filter_cart_price($price, $download_id, $options, $include_taxes = false)
{
    global $edd_options;
    $price = false;
    if (edd_has_variable_prices($download_id) && !empty($options)) {