本文整理汇总了PHP中edd_get_cart_tax函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_cart_tax函数的具体用法?PHP edd_get_cart_tax怎么用?PHP edd_get_cart_tax使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_cart_tax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_process_purchase_form
/**
* Process Purchase Form
*
* Handles the purchase form process.
*
* @access private
* @since 1.0
* @return void
*/
function edd_process_purchase_form()
{
do_action('edd_pre_process_purchase');
// Make sure the cart isn't empty
if (!edd_get_cart_contents() && !edd_cart_has_fees()) {
$valid_data = false;
edd_set_error('empty_cart', __('Your cart is empty', 'easy-digital-downloads'));
} else {
// Validate the form $_POST data
$valid_data = edd_purchase_form_validate_fields();
// Allow themes and plugins to hook to errors
do_action('edd_checkout_error_checks', $valid_data, $_POST);
}
$is_ajax = isset($_POST['edd_ajax']);
// Process the login form
if (isset($_POST['edd_login_submit'])) {
edd_process_purchase_login();
}
// Validate the user
$user = edd_get_purchase_form_user($valid_data);
if (false === $valid_data || edd_get_errors() || !$user) {
if ($is_ajax) {
do_action('edd_ajax_checkout_errors');
edd_die();
} else {
return false;
}
}
if ($is_ajax) {
echo 'success';
edd_die();
}
// Setup user information
$user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount'], 'address' => $user['address']);
$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
// Setup purchase information
$purchase_data = array('downloads' => edd_get_cart_contents(), 'fees' => edd_get_cart_fees(), 'subtotal' => edd_get_cart_subtotal(), 'discount' => edd_get_cart_discounted_amount(), 'tax' => edd_get_cart_tax(), 'price' => edd_get_cart_total(), 'purchase_key' => strtolower(md5($user['user_email'] . date('Y-m-d H:i:s') . $auth_key . uniqid('edd', true))), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s', current_time('timestamp')), 'user_info' => stripslashes_deep($user_info), 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
// Add the user data for hooks
$valid_data['user'] = $user;
// Allow themes and plugins to hook before the gateway
do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
// If the total amount in the cart is 0, send to the manual gateway. This emulates a free download purchase
if (!$purchase_data['price']) {
// Revert to manual
$purchase_data['gateway'] = 'manual';
$_POST['edd-gateway'] = 'manual';
}
// Allow the purchase data to be modified before it is sent to the gateway
$purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
// Setup the data we're storing in the purchase session
$session_data = $purchase_data;
// Make sure credit card numbers are never stored in sessions
unset($session_data['card_info']['card_number']);
// Used for showing download links to non logged-in users after purchase, and for other plugins needing purchase data.
edd_set_purchase_session($session_data);
// Send info to the gateway for payment processing
edd_send_to_gateway($purchase_data['gateway'], $purchase_data);
edd_die();
}
示例2: edd_process_purchase_form
/**
* Process Purchase Form
*
* Handles the purchase form process.
*
* @access private
* @since 1.0
* @version 1.0.8.1
* @return void
*/
function edd_process_purchase_form()
{
// no need to run on admin
if (is_admin()) {
return;
}
// verify the nonce for this action
if (!isset($_POST['edd-nonce']) || !wp_verify_nonce($_POST['edd-nonce'], 'edd-purchase-nonce')) {
return;
}
// make sure the cart isn't empty
$cart = edd_get_cart_contents();
if (empty($cart)) {
wp_die(sprintf(__('Your cart is empty, please return to the %ssite%s and try again.', 'edd'), '<a href="' . esc_url(home_url()) . '" title="' . get_bloginfo('name') . '">', '</a>'), __('Error', 'edd'));
}
// validate the form $_POST data
$valid_data = edd_purchase_form_validate_fields();
// allow themes and plugins to hoook to errors
do_action('edd_checkout_error_checks', $_POST);
// check errors
if (false !== ($errors = edd_get_errors())) {
// we have errors, send back to checkout
edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
exit;
}
// check user
if (false === ($user = edd_get_purchase_form_user($valid_data))) {
// something went wrong when collecting data, send back to checkout
edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
exit;
}
// setup user information
$user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
// setup purchase information
$purchase_data = array('downloads' => edd_get_cart_contents(), 'subtotal' => edd_get_cart_amount(false), 'tax' => edd_get_cart_tax(), 'price' => edd_get_cart_amount(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
// add the user data for hooks
$valid_data['user'] = $user;
// allow themes and plugins to hook before the gateway
do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
// allow the purchase data to be modified before it is sent to the gateway
$purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
// if the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
if ($purchase_data['price'] <= 0) {
// revert to manual
$valid_data['gateway'] = 'manual';
}
// used for showing download links to non logged-in users after purchase, and for other plugins needing purchase data.
edd_set_purchase_session($purchase_data);
// send info to the gateway for payment processing
edd_send_to_gateway($valid_data['gateway'], $purchase_data);
exit;
}
示例3: edd_process_purchase_form
/**
* Process Purchase Form
*
* Handles the purchase form process.
*
* @access private
* @since 1.0
* @version 1.0.8.1
* @return void
*/
function edd_process_purchase_form()
{
// Make sure the cart isn't empty
if (!edd_get_cart_contents()) {
edd_set_error('empty_cart', __('Your cart is empty', 'edd'));
} else {
// Validate the form $_POST data
$valid_data = edd_purchase_form_validate_fields();
// Allow themes and plugins to hoook to errors
do_action('edd_checkout_error_checks', $valid_data, $_POST);
}
$is_ajax = isset($_POST['edd_ajax']);
$user = edd_get_purchase_form_user($valid_data);
if (edd_get_errors() || !$user) {
if ($is_ajax) {
do_action('edd_ajax_checkout_errors');
edd_die();
} else {
return false;
}
}
if ($is_ajax) {
echo 'success';
edd_die();
}
// Setup user information
$user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
// Setup purchase information
$purchase_data = array('downloads' => edd_get_cart_contents(), 'fees' => edd_get_cart_fees(), 'subtotal' => edd_get_cart_subtotal(), 'discount' => edd_get_cart_discounted_amount(), 'tax' => edd_get_cart_tax(), 'price' => edd_get_cart_total(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
// Add the user data for hooks
$valid_data['user'] = $user;
// Allow themes and plugins to hook before the gateway
do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
// Allow the purchase data to be modified before it is sent to the gateway
$purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
// If the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
if (!$purchase_data['price']) {
// Revert to manual
$valid_data['gateway'] = 'manual';
}
// Used for showing download links to non logged-in users after purchase, and for other plugins needing purchase data.
edd_set_purchase_session($purchase_data);
// Send info to the gateway for payment processing
edd_send_to_gateway($valid_data['gateway'], $purchase_data);
edd_die();
}
示例4: edd_wallet_process_incentive
function edd_wallet_process_incentive()
{
if ($_REQUEST['gateway'] == 'wallet') {
EDD()->session->set('wallet_has_incentives', '1');
} else {
EDD()->session->set('wallet_has_incentives', null);
}
// Refresh the cart
if (empty($_POST['billing_country'])) {
$_POST['billing_country'] = edd_get_shop_country();
}
ob_start();
edd_checkout_cart();
$cart = ob_get_clean();
$response = array('html' => $cart, 'tax_raw' => edd_get_cart_tax(), 'tax' => html_entity_decode(edd_cart_tax(false), ENT_COMPAT, 'UTF-8'), 'tax_rate_raw' => edd_get_tax_rate(), 'tax_rate' => html_entity_decode(edd_get_formatted_tax_rate(), ENT_COMPAT, 'UTF-8'), 'total' => html_entity_decode(edd_cart_total(false), ENT_COMPAT, 'UTF-8'), 'total_raw' => edd_get_cart_total());
echo json_encode($response);
edd_die();
}
示例5: edd_points_get_discount_for_redeeming_points
/**
* Calculate Maximum Possible discount available
*
* Handles to calculate maximum possible discount
*
* @package Easy Digital Downloads - Points and Rewards
* @since 1.0.0
**/
public function edd_points_get_discount_for_redeeming_points()
{
global $edd_options;
//get users points
$available_user_disc = $this->edd_points_get_userpoints_value();
//get cart subtotal
$cartsubtotal = edd_get_cart_subtotal() - edd_get_cart_discounted_amount();
//check price is include tas or not
if (edd_prices_include_tax() == 'yes') {
$cartsubtotal = $cartsubtotal - edd_get_cart_tax();
}
//check user has points or not
if (empty($available_user_disc)) {
return 0;
}
//get cart content
$cartdata = edd_get_cart_contents();
$discount_applied = 0;
// calculate the discount to be applied by iterating through each item in the cart and calculating the individual
// maximum discount available
foreach ($cartdata as $item_key => $item) {
//max discount
$max_discount = $this->edd_points_get_max_points_discount_for_download($item['id']);
//check item of options set then consider that
if (isset($item['options'])) {
$itemoptions = $item['options'];
} elseif (isset($item['item_number']['options'])) {
$itemoptions = $item['item_number']['options'];
} else {
$itemoptions = array();
}
//get download price
$downloadprice = edd_get_cart_item_price($item['id'], $itemoptions);
if (is_numeric($max_discount)) {
// adjust the max discount by the quantity being ordered
$max_discount *= $item['quantity'];
// if the discount available is greater than the max discount, apply the max discount
$discount = $available_user_disc <= $max_discount ? $available_user_disc : $max_discount;
} else {
//when maximum discount is not set for product then allow maximum total cost of product as a discount
$max_price_discount = $downloadprice * $item['quantity'];
// if the discount available is greater than the max discount, apply the max discount
$discount = $available_user_disc <= $max_price_discount ? $available_user_disc : $max_price_discount;
}
// add the discount to the amount to be applied
$discount_applied += $discount;
// reduce the remaining discount available to be applied
$available_user_disc -= $discount;
}
//end for loop
// if the available discount is greater than the order total, make the discount equal to the order total less any other discounts
$discount_applied = max(0, min($discount_applied, $cartsubtotal));
//$discount_applied = max( 0, $discount_applied );
// limit the discount available by the global maximum discount if set
$max_discount = $edd_options['edd_points_cart_max_discount'];
if ($max_discount && $max_discount < $discount_applied) {
$discount_applied = $max_discount;
}
return $discount_applied;
}
示例6: edd_cart_tax
/**
* Gets the total tax amount for the cart contents in a fully formatted way
*
* @since 1.2.3
* @param bool $echo Whether to echo the tax amount or not (default: false)
* @return string Total tax amount (if $echo is set to true)
*/
function edd_cart_tax($echo = false)
{
$cart_tax = 0;
if (edd_is_cart_taxed()) {
$cart_tax = edd_get_cart_tax();
$cart_tax = edd_currency_filter(edd_format_amount($cart_tax));
}
$tax = apply_filters('edd_cart_tax', $cart_tax);
if (!$echo) {
return $tax;
}
echo $tax;
}
示例7: do_action
echo ' style="display:none;"';
}
?>
>
<?php
do_action('edd_checkout_table_tax_first');
?>
<th colspan="<?php
echo edd_checkout_cart_columns();
?>
" class="edd_cart_tax">
<?php
esc_html_e('Tax', 'helium');
?>
: <span class="edd_cart_tax_amount" data-tax="<?php
echo edd_get_cart_tax(false);
?>
"><?php
echo esc_html(edd_cart_tax());
?>
</span>
</th>
<?php
do_action('edd_checkout_table_tax_last');
?>
</tr>
<?php
}
?>
示例8: printf
if (!edd_prices_show_tax_on_checkout()) {
?>
<div class="row iceberg--small">
<div class="grid">
<div class="three-seventh offset-three-seventh small-four-fifth">
<?php
printf(__('VAT (<span class="yst-tax-rate">%s</span>%%)', 'yoastcom'), number_format(edd_get_tax_rate() * 100, 1));
?>
</div>
<div class="one-seventh small-one-fifth">
<span class="edd_cart_tax_amount" id="yst_main_tax" data-tax="<?php
echo esc_attr(edd_get_cart_tax());
?>
">
<?php
echo esc_html(edd_currency_filter(edd_format_amount(edd_get_cart_tax())));
?>
</span>
</div>
</div>
</div>
<?php
}
?>
<?php
}
?>
<hr class="hr--no-pointer tight">
<div class="row iceberg">
示例9: cart_has_tax
/**
* Returns whether or not the cart actually has taxes (ea. more then zero)
*
* @return bool
*/
function cart_has_tax()
{
return 0.0 !== (double) edd_get_cart_tax();
}
示例10: edd_get_cart_amount
/**
* Get Cart Amount
*
* @since 1.0
* @deprecated 1.9
* @param bool $add_taxes Whether to apply taxes (if enabled) (default: true)
* @param bool $local_override Force the local opt-in param - used for when not reading $_POST (default: false)
* @return float Total amount
*/
function edd_get_cart_amount($add_taxes = true, $local_override = false)
{
$backtrace = debug_backtrace();
_edd_deprecated_function(__FUNCTION__, '1.9', 'edd_get_cart_subtotal() or edd_get_cart_total()', $backtrace);
$amount = edd_get_cart_subtotal();
if (!empty($_POST['edd-discount']) || edd_get_cart_discounts() !== false) {
// Retrieve the discount stored in cookies
$discounts = edd_get_cart_discounts();
// Check for a posted discount
$posted_discount = isset($_POST['edd-discount']) ? trim($_POST['edd-discount']) : '';
if ($posted_discount && !in_array($posted_discount, $discounts)) {
// This discount hasn't been applied, so apply it
$amount = edd_get_discounted_amount($posted_discount, $amount);
}
if (!empty($discounts)) {
// Apply the discounted amount from discounts already applied
$amount -= edd_get_cart_discounted_amount();
}
}
if (edd_use_taxes() && edd_is_cart_taxed() && $add_taxes) {
$tax = edd_get_cart_tax();
$amount += $tax;
}
if ($amount < 0) {
$amount = 0.0;
}
return apply_filters('edd_get_cart_amount', $amount, $add_taxes, $local_override);
}
示例11: edd_ajax_recalculate_taxes
/**
* Recalculate cart taxes
*
* @since 1.6
* @return void
*/
function edd_ajax_recalculate_taxes()
{
if (!edd_get_cart_contents()) {
return false;
}
if (empty($_POST['billing_country'])) {
$_POST['billing_country'] = edd_get_shop_country();
}
ob_start();
edd_checkout_cart();
$cart = ob_get_clean();
$response = array('html' => $cart, 'tax_raw' => edd_get_cart_tax(), 'tax' => html_entity_decode(edd_cart_tax(false), ENT_COMPAT, 'UTF-8'), 'tax_rate_raw' => edd_get_tax_rate(), 'tax_rate' => html_entity_decode(edd_get_formatted_tax_rate(), ENT_COMPAT, 'UTF-8'), 'total' => html_entity_decode(edd_cart_total(false), ENT_COMPAT, 'UTF-8'), 'total_raw' => edd_get_cart_total());
echo json_encode($response);
edd_die();
}
示例12: do_action
<?php do_action( 'edd_checkout_table_subtotal_last' ); ?>
</tr>
<?php endif; ?>
<tr class="edd_cart_footer_row edd_cart_discount_row" <?php if( ! edd_cart_has_discounts() ) echo ' style="display:none;"'; ?>>
<?php do_action( 'edd_checkout_table_discount_first' ); ?>
<th colspan="<?php echo edd_checkout_cart_columns(); ?>" class="edd_cart_discount">
<?php edd_cart_discounts_html(); ?>
</th>
<?php do_action( 'edd_checkout_table_discount_last' ); ?>
</tr>
<?php if( edd_use_taxes() ) : ?>
<tr class="edd_cart_footer_row edd_cart_tax_row"<?php if( ! edd_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
<?php do_action( 'edd_checkout_table_tax_first' ); ?>
<th colspan="<?php echo edd_checkout_cart_columns(); ?>" class="edd_cart_tax">
<?php _e( 'Tax', 'edd' ); ?>: <span class="edd_cart_tax_amount" data-tax="<?php echo edd_get_cart_tax( false ); ?>"><?php echo esc_html( edd_cart_tax() ); ?></span>
</th>
<?php do_action( 'edd_checkout_table_tax_last' ); ?>
</tr>
<?php endif; ?>
<tr class="edd_cart_footer_row">
<?php do_action( 'edd_checkout_table_footer_first' ); ?>
<th colspan="<?php echo edd_checkout_cart_columns(); ?>" class="edd_cart_total"><?php _e( 'Total', 'edd' ); ?>: <span class="edd_cart_amount" data-subtotal="<?php echo edd_get_cart_total(); ?>" data-total="<?php echo edd_get_cart_total(); ?>"><?php edd_cart_total(); ?></span></th>
<?php do_action( 'edd_checkout_table_footer_last' ); ?>
</tr>
</tfoot>
</table>
示例13: edd_insert_payment
/**
* Insert Payment
*
* @since 1.0
* @param array $payment_data
* @return bool true if payment is inserted, false otherwise
*/
function edd_insert_payment($payment_data = array())
{
if (empty($payment_data)) {
return false;
}
// Construct the payment title
if (isset($payment_data['user_info']['first_name']) || isset($payment_data['user_info']['last_name'])) {
$payment_title = $payment_data['user_info']['first_name'] . ' ' . $payment_data['user_info']['last_name'];
} else {
$payment_title = $payment_data['user_email'];
}
// Retrieve the ID of the discount used, if any
if ($payment_data['user_info']['discount'] != 'none') {
$discount = edd_get_discount_by_code($payment_data['user_info']['discount']);
}
$args = apply_filters('edd_insert_payment_args', array('post_title' => $payment_title, 'post_status' => isset($payment_data['status']) ? $payment_data['status'] : 'pending', 'post_type' => 'edd_payment', 'post_parent' => isset($payment_data['parent']) ? $payment_data['parent'] : null, 'post_date' => isset($payment_data['post_date']) ? $payment_data['post_date'] : null, 'post_date_gmt' => isset($payment_data['post_date']) ? $payment_data['post_date'] : null), $payment_data);
// Create a blank payment
$payment = wp_insert_post($args);
if ($payment) {
$payment_meta = array('currency' => $payment_data['currency'], 'downloads' => serialize($payment_data['downloads']), 'user_info' => serialize($payment_data['user_info']), 'cart_details' => serialize($payment_data['cart_details']), 'tax' => edd_is_cart_taxed() ? edd_get_cart_tax() : 0);
$mode = edd_is_test_mode() ? 'test' : 'live';
$gateway = isset($_POST['edd-gateway']) ? $_POST['edd-gateway'] : '';
// Record the payment details
update_post_meta($payment, '_edd_payment_meta', apply_filters('edd_payment_meta', $payment_meta, $payment_data));
update_post_meta($payment, '_edd_payment_user_id', $payment_data['user_info']['id']);
update_post_meta($payment, '_edd_payment_user_email', $payment_data['user_email']);
update_post_meta($payment, '_edd_payment_user_ip', edd_get_ip());
update_post_meta($payment, '_edd_payment_purchase_key', $payment_data['purchase_key']);
update_post_meta($payment, '_edd_payment_total', $payment_data['price']);
update_post_meta($payment, '_edd_payment_mode', $mode);
update_post_meta($payment, '_edd_payment_gateway', $gateway);
if (!empty($discount)) {
update_post_meta($payment, '_edd_payment_discount_id', $discount->ID);
}
// Clear the user's purchased cache
delete_transient('edd_user_' . $payment_data['user_info']['id'] . '_purchases');
do_action('edd_insert_payment', $payment, $payment_data);
return $payment;
// Return the ID
}
// Return false if no payment was inserted
return false;
}
示例14: edd_cart_tax
/**
* Gets the total tax amount for the cart contents
*
* Returns a fully formatted amount
*
* @access public
* @since 1.2.3
* @return string
*/
function edd_cart_tax($echo = false)
{
$cart_tax = edd_get_cart_tax();
$cart_tax = edd_currency_filter(edd_format_amount($cart_tax));
$tax = apply_filters('edd_cart_tax', $cart_tax);
if ($echo) {
echo $tax;
}
return $tax;
}
示例15: edd_record_taxed_amount
/**
* Stores the tax info in the payment meta
*
* @access public
* @since 1.3.3
* @param $payment_meta array The meta data to store with the payment
* @param $payment_data array The info sent from process-purchase.php
* @return array
*/
function edd_record_taxed_amount($payment_meta, $payment_data)
{
if (!edd_use_taxes()) {
return $payment_meta;
}
if (edd_local_taxes_only() && isset($_POST['edd_tax_opt_in'])) {
// calculate local taxes
$payment_meta['subtotal'] = edd_get_cart_amount(false);
$payment_meta['tax'] = edd_get_cart_tax();
} elseif (!edd_local_taxes_only()) {
// calculate global taxes
$payment_meta['subtotal'] = edd_get_cart_amount(false);
$payment_meta['tax'] = edd_get_cart_tax();
}
return $payment_meta;
}