?> " 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 esc_html_e('Tax', 'helium'); ?> : <span class="edd_cart_tax_amount" data-tax="<?php
/** * 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; }
/** * 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); }
/** * Should we show address fields for taxation purposes? * * @since 1.y * @return bool */ function edd_cart_needs_tax_address_fields() { if (!edd_is_cart_taxed()) { return false; } return !did_action('edd_after_cc_fields', 'edd_default_cc_address_fields'); }
<?php _e( 'Subtotal', 'edd' ); ?>: <span class="edd_cart_subtotal_amount"><?php echo edd_cart_subtotal(); ?></span> </th> <?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>
/** * 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; }
/** * 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; }