本文整理汇总了PHP中edd_prices_include_tax函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_prices_include_tax函数的具体用法?PHP edd_prices_include_tax怎么用?PHP edd_prices_include_tax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_prices_include_tax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: edd_calculate_tax
/**
* Calculate the taxed amount
*
* @since 1.3.3
* @param $amount float The original amount to calculate a tax cost
* @param $country string The country to calculate tax for. Will use default if not passed
* @param $state string The state to calculate tax for. Will use default if not passed
* @return float $tax Taxed amount
*/
function edd_calculate_tax($amount = 0, $country = false, $state = false)
{
global $edd_options;
$rate = edd_get_tax_rate($country, $state);
$tax = 0.0;
if (edd_use_taxes()) {
if (edd_prices_include_tax()) {
$pre_tax = $amount / (1 + $rate);
$tax = $amount - $pre_tax;
} else {
$tax = $amount * $rate;
}
}
return apply_filters('edd_taxed_amount', $tax, $rate, $country, $state);
}
示例3: edd_tools_sysinfo_get
//.........这里部分代码省略.........
$return .= "\n" . '-- EDD Page Configuration' . "\n\n";
$return .= 'Checkout: ' . (!empty($edd_options['purchase_page']) ? "Valid\n" : "Invalid\n");
$return .= 'Checkout Page: ' . (!empty($edd_options['purchase_page']) ? get_permalink($edd_options['purchase_page']) . "\n" : "Unset\n");
$return .= 'Success Page: ' . (!empty($edd_options['success_page']) ? get_permalink($edd_options['success_page']) . "\n" : "Unset\n");
$return .= 'Failure Page: ' . (!empty($edd_options['failure_page']) ? get_permalink($edd_options['failure_page']) . "\n" : "Unset\n");
$return .= 'Downloads Slug: ' . (defined('EDD_SLUG') ? '/' . EDD_SLUG . "\n" : "/downloads\n");
$return = apply_filters('edd_sysinfo_after_edd_pages', $return);
// EDD gateways
$return .= "\n" . '-- EDD Gateway Configuration' . "\n\n";
$active_gateways = edd_get_enabled_payment_gateways();
if ($active_gateways) {
$default_gateway_is_active = edd_is_gateway_active(edd_get_default_gateway());
if ($default_gateway_is_active) {
$default_gateway = edd_get_default_gateway();
$default_gateway = $active_gateways[$default_gateway]['admin_label'];
} else {
$default_gateway = 'Test Payment';
}
$gateways = array();
foreach ($active_gateways as $gateway) {
$gateways[] = $gateway['admin_label'];
}
$return .= 'Enabled Gateways: ' . implode(', ', $gateways) . "\n";
$return .= 'Default Gateway: ' . $default_gateway . "\n";
} else {
$return .= 'Enabled Gateways: None' . "\n";
}
$return = apply_filters('edd_sysinfo_after_edd_gateways', $return);
// EDD Taxes
$return .= "\n" . '-- EDD Tax Configuration' . "\n\n";
$return .= 'Taxes: ' . (edd_use_taxes() ? "Enabled\n" : "Disabled\n");
$return .= 'Tax Rate: ' . edd_get_tax_rate() * 100 . "\n";
$return .= 'Display On Checkout: ' . (!empty($edd_options['checkout_include_tax']) ? "Displayed\n" : "Not Displayed\n");
$return .= 'Prices Include Tax: ' . (edd_prices_include_tax() ? "Yes\n" : "No\n");
$rates = edd_get_tax_rates();
if (!empty($rates)) {
$return .= 'Country / State Rates: ' . "\n";
foreach ($rates as $rate) {
$return .= ' Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . "\n";
}
}
$return = apply_filters('edd_sysinfo_after_edd_taxes', $return);
// EDD Templates
$dir = get_stylesheet_directory() . '/edd_templates/*';
if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) {
$return .= "\n" . '-- EDD Template Overrides' . "\n\n";
foreach (glob($dir) as $file) {
$return .= 'Filename: ' . basename($file) . "\n";
}
$return = apply_filters('edd_sysinfo_after_edd_templates', $return);
}
// WordPress active plugins
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
$plugins = get_plugins();
$active_plugins = get_option('active_plugins', array());
foreach ($plugins as $plugin_path => $plugin) {
if (!in_array($plugin_path, $active_plugins)) {
continue;
}
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
}
$return = apply_filters('edd_sysinfo_after_wordpress_plugins', $return);
// WordPress inactive plugins
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
foreach ($plugins as $plugin_path => $plugin) {
if (in_array($plugin_path, $active_plugins)) {
示例4: edd_calculate_tax
/**
* Calculate the taxed amount
*
* @since 1.3.3
* @param $amount float The original amount to calculate a tax cost
* @return float $tax Taxed amount
*/
function edd_calculate_tax($amount, $sum = true)
{
global $edd_options;
// Not using taxes
if (!edd_use_taxes()) {
return $amount;
}
$rate = edd_get_tax_rate();
$tax = 0.0;
$prices_include_tax = edd_prices_include_tax();
if ($prices_include_tax) {
$tax = $amount - $amount / ($rate + 1);
} else {
$tax = $amount * $rate;
}
if ($sum) {
if ($prices_include_tax) {
$tax = $amount - $tax;
} else {
$tax = $amount + $tax;
}
}
return apply_filters('edd_taxed_amount', round($tax, 2), $rate);
}
示例5: edd_get_purchase_link
/**
* Get Purchase Link
*
* Builds a Purchase link for a specified download based on arguments passed.
* This function is used all over EDD to generate the Purchase or Add to Cart
* buttons. If no arguments are passed, the function uses the defaults that have
* been set by the plugin. The Purchase link is built for simple and variable
* pricing and filters are available throughout the function to override
* certain elements of the function.
*
* $download_id = null, $link_text = null, $style = null, $color = null, $class = null
*
* @since 1.0
* @param array $args Arguments for display
* @return string $purchase_form
*/
function edd_get_purchase_link($args = array())
{
global $edd_options, $post;
if (!isset($edd_options['purchase_page']) || $edd_options['purchase_page'] == 0) {
edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'edd'), admin_url('edit.php?post_type=download&page=edd-settings')));
edd_print_errors();
return false;
}
$post_id = is_object($post) ? $post->ID : 0;
$defaults = apply_filters('edd_purchase_link_defaults', array('download_id' => $post_id, 'price' => (bool) true, 'direct' => edd_get_download_button_behavior($post_id) == 'direct' ? true : false, 'text' => !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd'), 'style' => isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button', 'color' => isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue', 'class' => 'edd-submit'));
$args = wp_parse_args($args, $defaults);
if ('publish' != get_post_field('post_status', $args['download_id']) && !current_user_can('edit_product', $args['download_id'])) {
return false;
// Product not published or user doesn't have permission to view drafts
}
// Override color if color == inherit
$args['color'] = $args['color'] == 'inherit' ? '' : $args['color'];
$variable_pricing = edd_has_variable_prices($args['download_id']);
$data_variable = $variable_pricing ? ' data-variable-price="yes"' : 'data-variable-price="no"';
$type = edd_single_price_option_mode($args['download_id']) ? 'data-price-mode=multi' : 'data-price-mode=single';
if ($args['price'] && $args['price'] !== 'no' && !$variable_pricing) {
$price = edd_get_download_price($args['download_id']);
$button_text = !empty($args['text']) ? ' – ' . $args['text'] : '';
if (0 == $price) {
$args['text'] = __('Free', 'edd') . $button_text;
} else {
$args['text'] = edd_currency_filter(edd_format_amount($price)) . $button_text;
}
}
if (edd_item_in_cart($args['download_id']) && !$variable_pricing) {
$button_display = 'style="display:none;"';
$checkout_display = '';
} else {
$button_display = '';
$checkout_display = 'style="display:none;"';
}
global $edd_displayed_form_ids;
$form_id = !empty($args['form_id']) ? $args['form_id'] : 'edd_purchase_' . $args['download_id'];
$args = apply_filters('edd_purchase_link_args', $args);
ob_start();
?>
<form id="<?php
echo $form_id;
?>
" class="edd_download_purchase_form" method="post">
<?php
do_action('edd_purchase_link_top', $args['download_id'], $args);
?>
<div class="edd_purchase_submit_wrapper">
<?php
$class = implode(' ', array($args['style'], $args['color'], trim($args['class'])));
if (!edd_is_ajax_disabled()) {
echo '<a href="#" class="edd-add-to-cart ' . esc_attr($class) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($args['download_id']) . '" ' . $data_variable . ' ' . $type . ' ' . $button_display . '><span class="edd-add-to-cart-label">' . $args['text'] . '</span> <span class="edd-loading"><i class="edd-icon-spinner edd-icon-spin"></i></span></a>';
}
echo '<input type="submit" class="edd-add-to-cart edd-no-js ' . esc_attr($class) . '" name="edd_purchase_download" value="' . esc_attr($args['text']) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($args['download_id']) . '" ' . $data_variable . ' ' . $type . ' ' . $button_display . '/>';
echo '<a href="' . esc_url(edd_get_checkout_uri()) . '" class="edd_go_to_checkout ' . esc_attr($class) . '" ' . $checkout_display . '>' . __('Checkout', 'edd') . '</a>';
?>
<?php
if (!edd_is_ajax_disabled()) {
?>
<span class="edd-cart-ajax-alert">
<span class="edd-cart-added-alert" style="display: none;">
<?php
printf(__('<i class="edd-icon-ok"></i> Added to cart', 'edd'), '<a href="' . esc_url(edd_get_checkout_uri()) . '" title="' . __('Go to Checkout', 'edd') . '">', '</a>');
?>
</span>
</span>
<?php
}
?>
<?php
if (edd_display_tax_rate() && edd_prices_include_tax()) {
echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Includes %1$s% tax', 'edd'), edd_get_tax_rate() * 100) . '</span>';
} elseif (edd_display_tax_rate() && !edd_prices_include_tax()) {
echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Excluding %1$s% tax', 'edd'), edd_get_tax_rate() * 100) . '</span>';
}
?>
</div><!--end .edd_purchase_submit_wrapper-->
<input type="hidden" name="download_id" value="<?php
echo esc_attr($args['download_id']);
//.........这里部分代码省略.........
示例6: edds_process_stripe_payment
/**
* Process stripe checkout submission
*
* @access public
* @since 1.0
* @return void
*/
function edds_process_stripe_payment($purchase_data)
{
global $edd_options;
if (!class_exists('Stripe')) {
require_once EDDS_PLUGIN_DIR . '/Stripe/Stripe.php';
}
if (edd_is_test_mode()) {
$secret_key = trim($edd_options['test_secret_key']);
} else {
$secret_key = trim($edd_options['live_secret_key']);
}
$purchase_summary = edd_get_purchase_summary($purchase_data, false);
// make sure we don't have any left over errors present
edd_clear_errors();
if (!isset($_POST['edd_stripe_token'])) {
// check for fallback mode
if (isset($edd_options['stripe_js_fallback'])) {
if (!isset($_POST['card_name']) || strlen(trim($_POST['card_name'])) == 0) {
edd_set_error('no_card_name', __('Please enter a name for the credit card.', 'edds'));
}
if (!isset($_POST['card_number']) || strlen(trim($_POST['card_number'])) == 0) {
edd_set_error('no_card_number', __('Please enter a credit card number.', 'edds'));
}
if (!isset($_POST['card_cvc']) || strlen(trim($_POST['card_cvc'])) == 0) {
edd_set_error('no_card_cvc', __('Please enter a CVC/CVV for the credit card.', 'edds'));
}
if (!isset($_POST['card_exp_month']) || strlen(trim($_POST['card_exp_month'])) == 0) {
edd_set_error('no_card_exp_month', __('Please enter a expiration month.', 'edds'));
}
if (!isset($_POST['card_exp_year']) || strlen(trim($_POST['card_exp_year'])) == 0) {
edd_set_error('no_card_exp_year', __('Please enter a expiration year.', 'edds'));
}
$card_data = array('number' => $purchase_data['card_info']['card_number'], 'name' => $purchase_data['card_info']['card_name'], 'exp_month' => $purchase_data['card_info']['card_exp_month'], 'exp_year' => $purchase_data['card_info']['card_exp_year'], 'cvc' => $purchase_data['card_info']['card_cvc'], 'address_line1' => $purchase_data['card_info']['card_address'], 'address_line2' => $purchase_data['card_info']['card_address_2'], 'address_city' => $purchase_data['card_info']['card_city'], 'address_zip' => $purchase_data['card_info']['card_zip'], 'address_state' => $purchase_data['card_info']['card_state'], 'address_country' => $purchase_data['card_info']['card_country']);
} else {
// no Stripe token
edd_set_error('no_token', __('Missing Stripe token. Please contact support.', 'edds'));
edd_record_gateway_error(__('Missing Stripe Token', 'edds'), __('A Stripe token failed to be generated. Please check Stripe logs for more information', ' edds'));
}
} else {
$card_data = $_POST['edd_stripe_token'];
}
$errors = edd_get_errors();
if (!$errors) {
try {
Stripe::setApiKey($secret_key);
// setup the payment details
$payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending', 'gateway' => 'stripe');
$customer_exists = false;
if (is_user_logged_in()) {
$user = get_user_by('email', $purchase_data['user_email']);
if ($user) {
$customer_id = get_user_meta($user->ID, edd_stripe_get_customer_key(), true);
if ($customer_id) {
$customer_exists = true;
try {
// Update the customer to ensure their card data is up to date
$cu = Stripe_Customer::retrieve($customer_id);
if (isset($cu->deleted) && $cu->deleted) {
// This customer was deleted
$customer_exists = false;
} else {
$cu->card = $card_data;
$cu->save();
}
// No customer found
} catch (Exception $e) {
$customer_exists = false;
}
}
}
}
if (!$customer_exists) {
// Create a customer first so we can retrieve them later for future payments
$customer = Stripe_Customer::create(array('description' => $purchase_data['user_email'], 'email' => $purchase_data['user_email'], 'card' => $card_data));
$customer_id = is_array($customer) ? $customer['id'] : $customer->id;
if (is_user_logged_in()) {
update_user_meta($user->ID, edd_stripe_get_customer_key(), $customer_id);
}
}
if (edds_is_recurring_purchase($purchase_data) && (!empty($customer) || $customer_exists)) {
// Process a recurring subscription purchase
$cu = Stripe_Customer::retrieve($customer_id);
/**********************************************************
* Taxes, fees, and discounts have to be handled differently
* with recurring subscriptions, so each is added as an
* invoice item and then charged as one time items
**********************************************************/
$invoice_items = array();
$needs_invoiced = false;
if ($purchase_data['tax'] > 0 && !edd_prices_include_tax()) {
if (edds_is_zero_decimal_currency()) {
$tax = $purchase_data['tax'];
} else {
//.........这里部分代码省略.........
示例7: edd_cart_item_price
/**
* Get Cart Item Price
*
* @since 1.0
*
* @param int $item_id Download (cart item) ID number
* @param array $options Optional parameters, used for defining variable prices
* @return string Fully formatted price
*/
function edd_cart_item_price($item_id = 0, $options = array())
{
$price = edd_get_cart_item_price($item_id, $options);
$label = '';
$price_id = isset($options['price_id']) ? $options['price_id'] : false;
if (!edd_is_free_download($item_id, $price_id) && !edd_download_is_tax_exclusive($item_id)) {
if (edd_prices_show_tax_on_checkout() && !edd_prices_include_tax()) {
$price += edd_get_cart_item_tax($item_id, $options, $price);
}
if (!edd_prices_show_tax_on_checkout() && edd_prices_include_tax()) {
$price -= edd_get_cart_item_tax($item_id, $options, $price);
}
if (edd_display_tax_rate()) {
$label = ' – ';
if (edd_prices_show_tax_on_checkout()) {
$label .= sprintf(__('includes %s tax', 'edd'), edd_get_formatted_tax_rate());
} else {
$label .= sprintf(__('excludes %s tax', 'edd'), edd_get_formatted_tax_rate());
}
$label = apply_filters('edd_cart_item_tax_description', $label, $item_id, $options);
}
}
$price = edd_currency_filter(edd_format_amount($price));
return apply_filters('edd_cart_item_price_label', $price . $label, $item_id, $options);
}
示例8: payment_creation_form
public static function payment_creation_form()
{
// Determine our float accuracy for the steps and rounding
$decimals = edd_currency_decimal_filter();
if (empty($decimals)) {
$step = 1;
} else {
$i = 1;
$step = '0.';
while ($i < $decimals) {
$step .= '0';
$i++;
}
$step .= '1';
$step = (double) $step;
}
$tax_included = 'false';
if (edd_use_taxes() && edd_prices_include_tax()) {
$tax_included = 'true';
}
$columns = 4;
?>
<div class="wrap">
<h2><?php
_e('Create New Payment', 'edd-manual-purchases');
?>
</h2>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(document.body).on('input', '.edd-mp-amount,.edd-mp-tax,.edd-mp-quantity', function() {
eddmp_update_total();
});
// check for variable prices
$('#edd_mp_create_payment').on('change', '.mp-downloads', function() {
var $this = $(this);
var selected_download = $('option:selected', this).val();
$this.parent().parent().find('.download-price-option-wrap').html('');
if( parseInt( selected_download ) != 0) {
var edd_mp_nonce = $('#edd_create_payment_nonce').val();
var key = $this.parent().parent().data('key');
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'edd_mp_check_for_variations',
download_id: selected_download,
key: key,
nonce: edd_mp_nonce
},
dataType: "json",
success: function(response) {
$this.parent().parent().find('.download-price-option-wrap').html( response.html );
$this.parent().parent().find('input[name="downloads['+ key +'][amount]"]').val( response.amount );
eddmp_update_total();
}
}).fail(function (data) {
if ( window.console && window.console.log ) {
console.log( data );
}
});
} else {
$this.parent().parent().find('.download-price-option-wrap').html('N/A');
}
});
// Update the price when a variation changes
$('#edd_mp_create_payment').on('change', '.edd-mp-price-select', function() {
var $this = $(this);
var price_id = $('option:selected', this).val();
var edd_mp_nonce = $('#edd_create_payment_nonce').val();
var key = $this.parent().parent().data('key');
var download_id = $('select[name="downloads[' + key + '][id]"]').val();
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'edd_mp_variation_change',
download_id: download_id,
price_id: price_id,
key: key,
nonce: edd_mp_nonce
},
dataType: "json",
success: function(response) {
$this.parent().parent().find('input[name="downloads['+ key +'][amount]"]').val( response.amount );
eddmp_update_total();
}
}).fail(function (data) {
if ( window.console && window.console.log ) {
console.log( data );
}
});
});
$('.edd_add_repeatable').click(function() {
setTimeout( function() {
//.........这里部分代码省略.........
示例9: edd_cart_item_price
/**
* Get Cart Item Price
*
* @since 1.0
*
* @param int $item_id Download (cart item) ID number
* @param array $options Optional parameters, used for defining variable prices
* @return string Fully formatted price
*/
function edd_cart_item_price($item_id = 0, $options = array())
{
global $edd_options;
$price = edd_get_cart_item_price($item_id, $options);
$label = '';
if (edd_prices_show_tax_on_checkout() && !edd_prices_include_tax()) {
$price += edd_get_cart_item_tax($item_id, $options, $price);
}
if (!edd_prices_show_tax_on_checkout() && edd_prices_include_tax()) {
$price -= edd_get_cart_item_tax($item_id, $options, $price);
}
$price = edd_currency_filter(edd_format_amount($price));
if (edd_display_tax_rate()) {
$label = ' – ';
if (edd_prices_show_tax_on_checkout()) {
$label .= sprintf(__('includes %s tax', 'edd'), edd_get_formatted_tax_rate());
} else {
$label .= sprintf(__('excludes %s tax', 'edd'), edd_get_formatted_tax_rate());
}
}
return esc_html($price . $label);
}
示例10: checkout_maybe_display_sale_price
/**
* Checkout sale price.
*
* Display the sale price, and the regular price with a strike at the checkout.
* This requires a hook added in EDD 2.3.0
*
* @since 1.0.0, EDD 2.4.0
*
* @param double $price Regular price of the product.
* @param int $download_id ID of the download we're changing the price for.
* @return double The new price, if the product is in sale this will be the sale price.
*/
public function checkout_maybe_display_sale_price($label, $item_id, $options)
{
global $edd_options;
$download = new EDD_Download($item_id);
$regular_price = get_post_meta($item_id, 'edd_price', true);
$price = edd_get_cart_item_price($item_id, $options);
// Get sale price if it exists
if ($download->has_variable_prices()) {
$prices = $download->get_prices();
$regular_price = isset($prices[$options['price_id']]['regular_amount']) ? $prices[$options['price_id']]['regular_amount'] : $regular_price;
$sale_price = $prices[$options['price_id']]['sale_price'];
} else {
$sale_price = get_post_meta($item_id, 'edd_sale_price', true);
}
// Bail if no sale price is set
if (empty($sale_price)) {
return $label;
}
$label = '';
$price_id = isset($options['price_id']) ? $options['price_id'] : false;
if (!edd_is_free_download($item_id, $price_id) && !edd_download_is_tax_exclusive($item_id)) {
if (edd_prices_show_tax_on_checkout() && !edd_prices_include_tax()) {
$regular_price += edd_get_cart_item_tax($item_id, $options, $regular_price);
$price += edd_get_cart_item_tax($item_id, $options, $price);
}
if (!edd_prices_show_tax_on_checkout() && edd_prices_include_tax()) {
$regular_price -= edd_get_cart_item_tax($item_id, $options, $regular_price);
$price -= edd_get_cart_item_tax($item_id, $options, $price);
}
if (edd_display_tax_rate()) {
$label = ' – ';
if (edd_prices_show_tax_on_checkout()) {
$label .= sprintf(__('includes %s tax', 'edd'), edd_get_formatted_tax_rate());
} else {
$label .= sprintf(__('excludes %s tax', 'edd'), edd_get_formatted_tax_rate());
}
$label = apply_filters('edd_cart_item_tax_description', $label, $item_id, $options);
}
}
$regular_price = '<del>' . edd_currency_filter(edd_format_amount($regular_price)) . '</del>';
$price = edd_currency_filter(edd_format_amount($price));
return $regular_price . ' ' . $price . $label;
}
示例11: eddpdfi_pdf_template_vat
//.........这里部分代码省略.........
$eddpdfi_pdf->SetTextColor($colors['body'][0], $colors['body'][1], $colors['body'][2]);
$eddpdfi_pdf->Cell(0, 6, $eddpdfi_payment_meta['key'], 0, 2, 'L', false);
$eddpdfi_pdf->SetX(60);
$eddpdfi_pdf->SetTextColor($colors['emphasis'][0], $colors['emphasis'][1], $colors['emphasis'][2]);
$eddpdfi_pdf->Cell(30, 6, __('Payment Status', 'eddpdfi'), 0, 0, 'L', false);
$eddpdfi_pdf->SetTextColor($colors['body'][0], $colors['body'][1], $colors['body'][2]);
$eddpdfi_pdf->Cell(0, 6, $eddpdfi_payment_status, 0, 2, 'L', false);
$eddpdfi_pdf->SetX(60);
$eddpdfi_pdf->SetTextColor($colors['emphasis'][0], $colors['emphasis'][1], $colors['emphasis'][2]);
$eddpdfi_pdf->Cell(30, 6, __('Payment Method', 'eddpdfi'), 0, 0, 'L', false);
$eddpdfi_pdf->SetTextColor($colors['body'][0], $colors['body'][1], $colors['body'][2]);
$eddpdfi_pdf->Cell(0, 6, $eddpdfi_payment_method, 0, 2, 'L', false);
$offset = apply_filters('eddpdfi_pdf_template_extra_fields', 0, 'color', $eddpdfi_pdf, $eddpdfi_payment, $eddpdfi_payment_meta, $eddpdfi_buyer_info, $colors);
$eddpdfi_pdf->SetXY(61, 120 + $offset);
$eddpdfi_pdf->SetFillColor($colors['header'][0], $colors['header'][1], $colors['header'][2]);
$eddpdfi_pdf->SetDrawColor($colors['border'][0], $colors['border'][1], $colors['border'][2]);
$eddpdfi_pdf->SetFont($fontb, '', 10);
$eddpdfi_pdf->Cell(140, 8, __('Invoice Items', 'eddpdfi'), 1, 2, 'C', true);
$eddpdfi_pdf->Ln(0.2);
$eddpdfi_pdf->SetX(61);
$eddpdfi_pdf->SetFillColor($colors['sub'][0], $colors['sub'][1], $colors['sub'][2]);
$eddpdfi_pdf->SetFont($font, '', 9);
$qenabled = version_compare(EDD_VERSION, "1.9") >= 0 ? true : (function_exists('edd_item_quanities_enabled') ? edd_item_quanities_enabled() : false);
$eddpdfi_pdf->Cell($qenabled ? 95 : 102, 7, __('PRODUCT NAME', 'eddpdfi'), 'BL', 0, 'L', true);
if ($qenabled) {
$eddpdfi_pdf->Cell(10, 7, __('#', 'eddpdfi'), 'B', 0, 0, true);
}
$eddpdfi_pdf->Cell($qenabled ? 35 : 38, 7, __('PRICE', 'eddpdfi'), 'BR', 0, 'R', true);
$eddpdfi_pdf->Ln(0.2);
$eddpdfi_pdf_downloads = isset($eddpdfi_payment_meta['cart_details']) ? maybe_unserialize($eddpdfi_payment_meta['cart_details']) : false;
$eddpdfi_pdf->Ln();
if ($eddpdfi_pdf_downloads) {
$eddpdfi_pdf->SetX(61);
$includes_taxes = edd_prices_include_tax();
foreach ($eddpdfi_pdf_downloads as $key => $download) {
$eddpdfi_pdf->SetX(61);
$eddpdfi_pdf->SetFont($font, '', 10);
$eddpdfi_download_id = isset($eddpdfi_payment_meta['cart_details']) ? $download['id'] : $download;
$eddpdfi_price_override = isset($eddpdfi_payment_meta['cart_details']) ? $download['price'] : null;
$user_info = maybe_unserialize($eddpdfi_payment_meta['user_info']);
$eddpdfi_final_download_price = edd_get_download_final_price($eddpdfi_download_id, $user_info, $eddpdfi_price_override);
if (isset($user_info['discount']) && $user_info['discount'] != 'none') {
$eddpdfi_discount = $user_info['discount'];
} else {
$eddpdfi_discount = __('None', 'eddpdfi');
}
// $eddpdfi_total_price = html_entity_decode( edd_currency_filter( edd_format_amount( $eddpdfi_payment_meta['amount'] ) ) );
$eddpdfi_download_title = html_entity_decode(get_the_title($eddpdfi_download_id), ENT_COMPAT, 'UTF-8');
if (edd_has_variable_prices($eddpdfi_download_id)) {
$eddpdfi_download_title .= ' - ' . edd_get_cart_item_price_name($download);
$options = $download['item_number']['options'];
}
// error_log(print_r($download,true));
$options['is_item'] = $eddpdfi_download_id;
$price = edd_get_cart_item_price($eddpdfi_download_id, $options, $includes_taxes);
$eddpdfi_download_price = ' ' . html_entity_decode(edd_currency_filter(edd_format_amount($price)), ENT_COMPAT, 'UTF-8');
// $eddpdfi_download_price = ' ' . html_entity_decode( edd_currency_filter( edd_format_amount( $eddpdfi_final_download_price ) ), ENT_COMPAT, 'UTF-8' );
$eddpdfi_pdf->Cell($qenabled ? 95 : 102, 8, $eddpdfi_download_title, 'B', 0, 'L', false);
if ($qenabled) {
$quantity = is_array($download) ? $download['quantity'] : 1;
$eddpdfi_pdf->Cell(10, 8, $quantity, 'B', 0, 'C', false);
}
$eddpdfi_pdf->Cell($qenabled ? 35 : 38, 8, $eddpdfi_download_price, 'B', 2, 'R', false);
}
$eddpdfi_pdf->Ln(5);
$eddpdfi_pdf->SetX(61);
示例12: edd_get_cart_total
/**
* Get Total Cart Amount
*
* Returns amount after taxes and discounts
*
* @since 1.4.1
* @global $edd_options Array of all the EDD Options
* @param array $discounts Array of discounts to apply (needed during AJAX calls)
* @return float Cart amount
*/
function edd_get_cart_total($discounts = false)
{
global $edd_options;
$subtotal = edd_get_cart_subtotal(edd_prices_include_tax());
$fees = edd_get_cart_fee_total();
$cart_tax = edd_is_cart_taxed() ? edd_get_cart_tax($discounts) : 0;
$discount = edd_get_cart_discounted_amount($discounts);
$total = $subtotal + $fees + $cart_tax - $discount;
return (double) apply_filters('edd_get_cart_total', $total);
}
示例13: edd_get_purchase_link
//.........这里部分代码省略.........
?>
" class="edd_download_purchase_form edd_purchase_<?php
echo absint($download->ID);
?>
" method="post">
<?php
do_action('edd_purchase_link_top', $download->ID, $args);
?>
<div class="edd_purchase_submit_wrapper">
<?php
$class = implode(' ', array($args['style'], $args['color'], trim($args['class'])));
if (!edd_is_ajax_disabled()) {
echo '<a href="#" class="edd-add-to-cart ' . esc_attr($class) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($download->ID) . '" ' . $data_variable . ' ' . $type . ' ' . $data_price . ' ' . $button_display . '><span class="edd-add-to-cart-label">' . $args['text'] . '</span> <span class="edd-loading"><i class="edd-icon-spinner edd-icon-spin"></i></span></a>';
}
echo '<input type="submit" class="edd-add-to-cart edd-no-js ' . esc_attr($class) . '" name="edd_purchase_download" value="' . esc_attr($args['text']) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($download->ID) . '" ' . $data_variable . ' ' . $type . ' ' . $button_display . '/>';
echo '<a href="' . esc_url(edd_get_checkout_uri()) . '" class="edd_go_to_checkout ' . esc_attr($class) . '" ' . $checkout_display . '>' . __('Checkout', 'easy-digital-downloads') . '</a>';
?>
<?php
if (!edd_is_ajax_disabled()) {
?>
<span class="edd-cart-ajax-alert">
<span class="edd-cart-added-alert" style="display: none;">
<?php
echo '<i class="edd-icon-ok"></i> ' . __('Added to cart', 'easy-digital-downloads');
?>
</span>
</span>
<?php
}
?>
<?php
if (!$download->is_free($args['price_id'])) {
?>
<?php
if (edd_display_tax_rate() && edd_prices_include_tax()) {
echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Includes %1$s% tax', 'easy-digital-downloads'), edd_get_tax_rate() * 100) . '</span>';
} elseif (edd_display_tax_rate() && !edd_prices_include_tax()) {
echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Excluding %1$s% tax', 'easy-digital-downloads'), edd_get_tax_rate() * 100) . '</span>';
}
?>
<?php
}
?>
</div><!--end .edd_purchase_submit_wrapper-->
<input type="hidden" name="download_id" value="<?php
echo esc_attr($download->ID);
?>
">
<?php
if ($variable_pricing && isset($price_id) && isset($prices[$price_id])) {
?>
<input type="hidden" name="edd_options[price_id][]" id="edd_price_option_<?php
echo $download->ID;
?>
_1" class="edd_price_option_<?php
echo $download->ID;
?>
" value="<?php
echo $price_id;
?>
">
<?php
}
?>
<?php
if (!empty($args['direct']) && !$download->is_free($args['price_id'])) {
?>
<input type="hidden" name="edd_action" class="edd_action_input" value="straight_to_gateway">
<?php
} else {
?>
<input type="hidden" name="edd_action" class="edd_action_input" value="add_to_cart">
<?php
}
?>
<?php
if (apply_filters('edd_download_redirect_to_checkout', edd_straight_to_checkout(), $download->ID, $args)) {
?>
<input type="hidden" name="edd_redirect_to_checkout" id="edd_redirect_to_checkout" value="1">
<?php
}
?>
<?php
do_action('edd_purchase_link_end', $download->ID, $args);
?>
</form><!--end #<?php
echo esc_attr($form_id);
?>
-->
<?php
$purchase_form = ob_get_clean();
return apply_filters('edd_purchase_download_form', $purchase_form, $args);
}
示例14: atcf_edd_add_to_cart_item
/**
* Custom pledge level fix.
*
* If there is a custom price, figure out the difference
* between that, and the price level they have chosen. Store
* the differene in the cart item meta, so it can be added to
* the total in the future.
*
* @since Astoundify Crowdfunding 1.6
*
* @param array $cart_item The current cart item to be added.
* @return array $cart_item The modified cart item.
*/
function atcf_edd_add_to_cart_item($cart_item)
{
if (isset($_POST['post_data'])) {
$post_data = array();
parse_str($_POST['post_data'], $post_data);
$custom_price = $post_data['atcf_custom_price'];
} else {
$custom_price = $_POST['atcf_custom_price'];
}
$custom_price = edd_sanitize_amount($custom_price);
$price = edd_get_cart_item_price($cart_item['id'], $cart_item['options'], edd_prices_include_tax());
if ($custom_price > $price) {
$cart_item['options']['atcf_extra_price'] = $custom_price - $price;
}
return $cart_item;
}
示例15: edd_get_cart_item_price
/**
* Get Cart Item Price
*
* Gets the price of the cart item. Always exclusive of taxes
*
* Do not use this for getting the final price (with taxes and discounts) of an item.
* Use edd_get_cart_item_final_price()
*
* @since 1.0
* @param int $download_id Download ID number
* @param array $options Optional parameters, used for defining variable prices
* @param bool $remove_tax_from_inclusive Remove the tax amount from tax inclusive priced products.
* @return float|bool Price for this item
*/
function edd_get_cart_item_price($download_id = 0, $options = array(), $remove_tax_from_inclusive = false)
{
$price = 0;
$variable_prices = edd_has_variable_prices($download_id);
if ($variable_prices) {
$prices = edd_get_variable_prices($download_id);
if ($prices) {
if (!empty($options)) {
$price = isset($prices[$options['price_id']]) ? $prices[$options['price_id']]['amount'] : false;
} else {
$price = false;
}
}
}
if (!$variable_prices || false === $price) {
// Get the standard Download price if not using variable prices
$price = edd_get_download_price($download_id);
}
if ($remove_tax_from_inclusive && edd_prices_include_tax()) {
$price -= edd_get_cart_item_tax($download_id, $options, $price);
}
return apply_filters('edd_cart_item_price', $price, $download_id, $options);
}