<div class="row iceberg--small"> <div class="grid"> <div class="three-seventh offset-three-seventh small-four-fifth"><?php _e('Subtotal', 'yoastcom'); ?> </div> <div class="one-seventh small-one-fifth edd_cart_subtotal_amount"> <?php echo esc_html(edd_currency_filter(edd_format_amount(edd_get_cart_subtotal() - edd_get_cart_discounted_amount()))); ?> </div> </div> </div> <?php 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())));
/** * 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); }
/** * 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); }
?> </tbody> <tfoot> <tr> <td<?php echo edd_use_skus() ? ' colspan="2"' : ''; ?> ><strong><?php _e('Total Price', 'edd'); ?> :</strong></td> <td> <?php echo edd_payment_amount($payment->ID); if (edd_use_taxes() && (!edd_prices_show_tax_on_checkout() && $edd_options['prices_include_tax'] == 'yes')) { echo ' ' . __('(ex. tax)', 'edd'); } else { if (edd_use_taxes() && $edd_options['checkout_include_tax'] == 'yes') { printf(' ' . __('(includes %s tax)', 'edd'), edd_payment_tax($payment->ID)); } } ?> </td> </tr> </tfoot> </table> <?php }
/** * 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; }
/** * Get Total Cart Amount * * Gets the fully formatted total price amount in the cart. * uses edd_get_cart_amount(). * * @access public * @global $edd_options Array of all the EDD Options * @since 1.3.3 * @return string - the cart amount */ function edd_cart_total($echo = true) { global $edd_options; $total = apply_filters('edd_cart_total', edd_currency_filter(edd_format_amount(edd_get_cart_total()))); if (edd_is_cart_taxed()) { if (edd_prices_show_tax_on_checkout()) { $total .= '<br/><span>' . sprintf(__('(includes %s tax)', 'edd'), edd_cart_tax()) . '</span>'; } } if (!$echo) { return $total; } echo $total; }
/** * Retrieves subtotal for payment (this is the amount before taxes) and then * returns a non formatted amount. * * @since 1.3.3 * @global $edd_options Array of all the EDD Options * @param int $payment_id Payment ID * @param bool $payment_meta Get payment meta? * @return float $subtotal Subtotal for payment (non formatted) */ function edd_get_payment_subtotal($payment_id = 0, $payment_meta = false) { global $edd_options; if (!$payment_meta) { $payment_meta = edd_get_payment_meta($payment_id); } $subtotal = isset($payment_meta['subtotal']) ? $payment_meta['subtotal'] : $payment_meta['amount']; $tax = edd_use_taxes() ? edd_get_payment_tax($payment_id) : 0; if (isset($edd_options['prices_include_tax']) && $edd_options['prices_include_tax'] == 'no' && !edd_prices_show_tax_on_checkout() || isset($edd_options['prices_include_tax']) && !edd_prices_show_tax_on_checkout() && $edd_options['prices_include_tax'] == 'yes') { $subtotal -= $tax; } return apply_filters('edd_get_payment_subtotal', $subtotal, $payment_id); }