当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_use_taxes函数代码示例

本文整理汇总了PHP中edd_use_taxes函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_use_taxes函数的具体用法?PHP edd_use_taxes怎么用?PHP edd_use_taxes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edd_use_taxes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edd_price

/**
 * 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;
    }
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:download-functions.php

示例2: edd_load_scripts

/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @since 1.0
 * @global $post
 * @return void
 */
function edd_load_scripts()
{
    global $post;
    $js_dir = EDD_PLUGIN_URL . 'assets/js/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    // Get position in cart of current download
    if (isset($post->ID)) {
        $position = edd_get_item_position_in_cart($post->ID);
    }
    if (edd_is_checkout()) {
        if (edd_is_cc_verify_enabled()) {
            wp_register_script('creditCardValidator', $js_dir . 'jquery.creditCardValidator' . $suffix . '.js', array('jquery'), EDD_VERSION);
            wp_enqueue_script('creditCardValidator');
        }
        wp_register_script('edd-checkout-global', $js_dir . 'edd-checkout-global' . $suffix . '.js', array('jquery'), EDD_VERSION);
        wp_enqueue_script('edd-checkout-global');
        wp_localize_script('edd-checkout-global', 'edd_global_vars', apply_filters('edd_global_checkout_script_vars', array('ajaxurl' => edd_get_ajax_url(), 'checkout_nonce' => wp_create_nonce('edd_checkout_nonce'), 'currency_sign' => edd_currency_filter(''), 'currency_pos' => edd_get_option('currency_position', 'before'), 'no_gateway' => __('Please select a payment method', 'edd'), 'no_discount' => __('Please enter a discount code', 'edd'), 'enter_discount' => __('Enter discount', 'edd'), 'discount_applied' => __('Discount Applied', 'edd'), 'no_email' => __('Please enter an email address before applying a discount code', 'edd'), 'no_username' => __('Please enter a username before applying a discount code', 'edd'), 'purchase_loading' => __('Please Wait...', 'edd'), 'complete_purchase' => __('Purchase', 'edd'), 'taxes_enabled' => edd_use_taxes() ? '1' : '0', 'edd_version' => EDD_VERSION)));
    }
    // Load AJAX scripts, if enabled
    if (!edd_is_ajax_disabled()) {
        wp_register_script('edd-ajax', $js_dir . 'edd-ajax' . $suffix . '.js', array('jquery'), EDD_VERSION);
        wp_enqueue_script('edd-ajax');
        wp_localize_script('edd-ajax', 'edd_scripts', apply_filters('edd_ajax_script_vars', array('ajaxurl' => edd_get_ajax_url(), 'position_in_cart' => isset($position) ? $position : -1, 'already_in_cart_message' => __('You have already added this item to your cart', 'edd'), 'empty_cart_message' => __('Your cart is empty', 'edd'), 'loading' => __('Loading', 'edd'), 'select_option' => __('Please select an option', 'edd'), 'ajax_loader' => set_url_scheme(EDD_PLUGIN_URL . 'assets/images/loading.gif', 'relative'), 'is_checkout' => edd_is_checkout() ? '1' : '0', 'default_gateway' => edd_get_default_gateway(), 'redirect_to_checkout' => edd_straight_to_checkout() || edd_is_checkout() ? '1' : '0', 'checkout_page' => edd_get_checkout_uri(), 'permalinks' => get_option('permalink_structure') ? '1' : '0', 'quantities_enabled' => edd_item_quantities_enabled(), 'taxes_enabled' => edd_use_taxes() ? '1' : '0')));
    }
}
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:35,代码来源:scripts.php

示例3: details

 /**
  * Get EDD details
  *
  * ## OPTIONS
  *
  * None. Returns basic info regarding your EDD instance.
  *
  * ## EXAMPLES
  *
  * wp edd details
  *
  * @access		public
  * @param		array $args
  * @param		array $assoc_args
  * @return		void
  */
 public function details($args, $assoc_args)
 {
     $symlink_file_downloads = edd_get_option('symlink_file_downloads', false);
     $purchase_page = edd_get_option('purchase_page', '');
     $success_page = edd_get_option('success_page', '');
     $failure_page = edd_get_option('failure_page', '');
     WP_CLI::line(sprintf(__('You are running EDD version: %s', 'easy-digital-downloads'), EDD_VERSION));
     WP_CLI::line("\n" . sprintf(__('Test mode is: %s', 'easy-digital-downloads'), edd_is_test_mode() ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Ajax is: %s', 'easy-digital-downloads'), edd_is_ajax_enabled() ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Guest checkouts are: %s', 'easy-digital-downloads'), edd_no_guest_checkout() ? __('Disabled', 'easy-digital-downloads') : __('Enabled', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Symlinks are: %s', 'easy-digital-downloads'), apply_filters('edd_symlink_file_downloads', isset($symlink_file_downloads)) && function_exists('symlink') ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads')));
     WP_CLI::line("\n" . sprintf(__('Checkout page is: %s', 'easy-digital-downloads'), !edd_get_option('purchase_page', false) ? __('Valid', 'easy-digital-downloads') : __('Invalid', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Checkout URL is: %s', 'easy-digital-downloads'), !empty($purchase_page) ? get_permalink($purchase_page) : __('Undefined', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Success URL is: %s', 'easy-digital-downloads'), !empty($success_page) ? get_permalink($success_page) : __('Undefined', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Failure URL is: %s', 'easy-digital-downloads'), !empty($failure_page) ? get_permalink($failure_page) : __('Undefined', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Downloads slug is: %s', 'easy-digital-downloads'), defined('EDD_SLUG') ? '/' . EDD_SLUG : '/downloads'));
     WP_CLI::line("\n" . sprintf(__('Taxes are: %s', 'easy-digital-downloads'), edd_use_taxes() ? __('Enabled', 'easy-digital-downloads') : __('Disabled', 'easy-digital-downloads')));
     WP_CLI::line(sprintf(__('Tax rate is: %s', 'easy-digital-downloads'), edd_get_tax_rate() * 100 . '%'));
     $rates = edd_get_tax_rates();
     if (!empty($rates)) {
         foreach ($rates as $rate) {
             WP_CLI::line(sprintf(__('Country: %s, State: %s, Rate: %s', 'easy-digital-downloads'), $rate['country'], $rate['state'], $rate['rate']));
         }
     }
 }
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:41,代码来源:class-edd-cli.php

示例4: edd_process_paypal_purchase

/**
 * Process PayPal Purchase
 *
 * @since 1.0
 * @global $edd_options Array of all the EDD Options
 * @param array $purchase_data Purchase Data
 * @return void
 */
function edd_process_paypal_purchase($purchase_data)
{
    global $edd_options;
    // Check there is a gateway name
    if (!isset($purchase_data['post_data']['edd-gateway'])) {
        return;
    }
    /*
    Purchase data comes in like this:
    
    $purchase_data = array(
        'downloads'     => array of download IDs,
        'tax' 			=> taxed amount on shopping cart
        'subtotal'		=> total price before tax
        'price'         => total price of cart contents after taxes,
        'purchase_key'  =>  // Random key
        'user_email'    => $user_email,
        'date'          => date( 'Y-m-d H:i:s' ),
        'user_id'       => $user_id,
        'post_data'     => $_POST,
        'user_info'     => array of user's information and used discount code
        'cart_details'  => array of cart details,
     );
    */
    // Collect payment data
    $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'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    // Check payment
    if (!$payment) {
        // Record the error
        edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
        // Problems? send back
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    } else {
        // Only send to PayPal if the pending payment is created successfully
        $listener_url = trailingslashit(home_url()) . '?edd-listener=IPN';
        // Get the success url
        $return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page']));
        // Get the complete cart cart_summary
        $summary = edd_get_purchase_summary($purchase_data, false);
        // Get the PayPal redirect uri
        $paypal_redirect = trailingslashit(edd_get_paypal_redirect()) . '?';
        // Setup PayPal arguments
        $paypal_args = array('cmd' => '_xclick', 'amount' => round($purchase_data['price'] - $purchase_data['tax'], 2), 'business' => $edd_options['paypal_email'], 'item_name' => stripslashes_deep(html_entity_decode(wp_strip_all_tags($summary), ENT_COMPAT, 'UTF-8')), 'email' => $purchase_data['user_email'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => edd_get_currency(), 'item_number' => $purchase_data['purchase_key'], 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'cancel_return' => edd_get_failed_transaction_uri(), 'notify_url' => $listener_url, 'page_style' => edd_get_paypal_page_style());
        if (edd_use_taxes()) {
            $paypal_args['tax'] = $purchase_data['tax'];
        }
        $paypal_args = apply_filters('edd_paypal_redirect_args', $paypal_args, $purchase_data);
        // Build query
        $paypal_redirect .= http_build_query($paypal_args);
        // Get rid of cart contents
        edd_empty_cart();
        // Redirect to PayPal
        wp_redirect($paypal_redirect);
        exit;
    }
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:66,代码来源:paypal-standard.php

示例5: edd_customerio_connect_register_user

/**
 * Track new users
 *
 * @since       1.0.0
 * @param       int $payment_id The ID of a given payment
 * @return      void
 */
function edd_customerio_connect_register_user($payment_id)
{
    // Bail if API isn't setup
    if (!edd_customerio_connect()->api) {
        return;
    }
    // Setup the request body
    $user_info = edd_get_payment_meta_user_info($payment_id);
    $payment_meta = edd_get_payment_meta($payment_id);
    $cart_items = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false;
    $user_name = false;
    if ($payment_meta['user_info']['first_name']) {
        $user_name = $payment_meta['user_info']['first_name'];
        if ($payment_meta['user_info']['last_name']) {
            $user_name .= ' ' . $payment_meta['user_info']['last_name'];
        }
    }
    $body = array('email' => $payment_meta['user_info']['email'], 'created_at' => $payment_meta['date']);
    if ($user_name) {
        $body['name'] = $user_name;
    }
    $response = edd_customerio_connect()->api->call($payment_meta['user_info']['id'], $body);
    // Track the purchases
    if (empty($cart_items) || !$cart_items) {
        $cart_items = maybe_unserialize($payment_meta['downloads']);
    }
    if ($cart_items) {
        $body = array('name' => 'purchased', 'data' => array('discount' => $payment_meta['user_info']['discount']));
        foreach ($cart_items as $key => $cart_item) {
            $item_id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item;
            $price = $cart_item['price'];
            $body['data']['items'][$cart_item['id']] = array('price' => $price, 'product_id' => $cart_item['id'], 'product_name' => esc_attr($cart_item['name']));
            if (edd_has_variable_prices($cart_item['id'])) {
                $body['data']['items'][$cart_item['id']]['price_id'] = $cart_item['item_number']['options']['price_id'];
                $body['data']['items'][$cart_item['id']]['price_name'] = edd_get_price_option_name($cart_item['id'], $cart_item['item_number']['options']['price_id']);
                $body['data']['items'][$cart_item['id']]['quantity'] = $cart_item['item_number']['quantity'];
            } else {
                $body['data']['items'][$cart_item['id']]['quantity'] = $cart_item['quantity'];
            }
            if (edd_use_taxes()) {
                $body['data']['items'][$cart_item['id']]['tax'] = $cart_item['tax'];
            }
        }
        $response = edd_customerio_connect()->api->call($payment_meta['user_info']['id'], $body, 'POST', 'events');
    }
}
开发者ID:easydigitaldownloads,项目名称:EDD-Customerio-Connect,代码行数:53,代码来源:actions.php

示例6: edd_get_cart_item_template

/**
 * 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);
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:27,代码来源:template.php

示例7: vp_edd_fd_get_calculated_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;
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:31,代码来源:edd-functions.php

示例8: edd_get_payment_subtotal

/**
 * Retrieves subtotal for payment (this is the amount before taxes) and then
 * returns a non formatted amount.
 *
 * @since 1.3.3
 * @param int $payment_id Payment ID
 * @return float $subtotal Subtotal for payment (non formatted)
 */
function edd_get_payment_subtotal($payment_id = 0)
{
    $subtotal = 0;
    $cart_details = edd_get_payment_meta_cart_details($payment_id);
    if (is_array($cart_details)) {
        foreach ($cart_details as $item) {
            if (isset($item['subtotal'])) {
                $subtotal += $item['subtotal'];
            }
        }
    } else {
        $subtotal = edd_get_payment_amount($payment_id);
        $tax = edd_use_taxes() ? edd_get_payment_tax($payment_id) : 0;
        $subtotal -= $tax;
    }
    return apply_filters('edd_get_payment_subtotal', $subtotal, $payment_id);
}
开发者ID:ankitpokhrel,项目名称:Easy-Digital-Downloads,代码行数:25,代码来源:functions.php

示例9: wallet_form

    /**
     * Display the wallet and address forms
     *
     * @access public
     * @since  2.4
     * @return void
     */
    public function wallet_form()
    {
        $profile = EDD()->session->get('amazon_profile');
        remove_action('edd_purchase_form_after_cc_form', 'edd_checkout_tax_fields', 999);
        ob_start();
        ?>
		<fieldset id="edd_cc_fields" class="edd-amazon-fields">
			<p class="edd-amazon-profile-wrapper">
				<?php 
        _e('Currently logged into Amazon as', 'edd');
        ?>
: <span class="edd-amazon-profile-name"><?php 
        echo $profile['name'];
        ?>
</span>
				<span class="edd-amazon-logout">(<a id="Logout"><?php 
        _e('Logout', 'edd');
        ?>
</a>)</span>
			</p>
			<?php 
        if (edd_use_taxes()) {
            ?>
				<div id="edd-amazon-address-box"></div>
			<?php 
        }
        ?>
			<div id="edd-amazon-wallet-box"></div>
			<script>
				var edd_scripts;
				if( '1' == edd_scripts.taxes_enabled ) {
					new OffAmazonPayments.Widgets.AddressBook({
						sellerId: edd_amazon.sellerId,
						amazonOrderReferenceId: edd_amazon.referenceID,
						onOrderReferenceCreate: function(orderReference) {
							orderReference.getAmazonOrderReferenceId();
						},
						onAddressSelect: function(orderReference) {
							jQuery.ajax({
								type: "POST",
								data: {
									action       : 'edd_amazon_get_address',
									reference_id : edd_amazon.referenceID
								},
								dataType: "json",
								url: edd_scripts.ajaxurl,
								xhrFields: {
									withCredentials: true
								},
								success: function (response) {
									jQuery('#card_city').val( response.City );
									jQuery('#card_address').val( response.AddressLine1 );
									jQuery('#card_address_2').val( response.AddressLine2 );
									jQuery('#card_zip').val( response.PostalCode );
									jQuery('#billing_country').val( response.CountryCode );
									jQuery('#card_state').val( response.StateOrRegion ).trigger( 'change' );
								}
							}).fail(function (response) {
								if ( window.console && window.console.log ) {
									console.log( response );
								}
							}).done(function (response) {

							});
						},
						design: {
							designMode: 'responsive'
						},
						onError: function(error) {
							jQuery('#edd-amazon-address-box').hide();
							jQuery('#edd_purchase_submit').prepend( '<div class="edd_errors"><p class="edd_error" id="edd_error_"' + error.getErrorCode() + '>' + error.getErrorMessage() + '</p></div>' );
						}
					}).bind("edd-amazon-address-box");

					new OffAmazonPayments.Widgets.Wallet({
						sellerId: edd_amazon.sellerId,
						amazonOrderReferenceId: edd_amazon.referenceID,
						design: {
							designMode: 'responsive'
						},
						onPaymentSelect: function(orderReference) {
							// Display your custom complete purchase button
						},
						onError: function(error) {
							jQuery('#edd_purchase_submit').prepend( '<div class="edd_errors"><p class="edd_error" id="edd_error_"' + error.getErrorCode() + '>' + error.getErrorMessage() + '</p></div>' );
						}
					}).bind("edd-amazon-wallet-box");

				} else {

					new OffAmazonPayments.Widgets.Wallet({
						sellerId: edd_amazon.sellerId,
						design: {
//.........这里部分代码省略.........
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:amazon-payments.php

示例10: edd_checkout_cart_columns

				<th colspan="<?php echo edd_checkout_cart_columns(); ?>" class="edd_cart_subtotal">
					<?php _e( 'Subtotal', 'edd' ); ?>:&nbsp;<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' ); ?>:&nbsp;<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>
开发者ID:harish94,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:checkout_cart.php

示例11: edd_show_local_tax_opt_in

/**
 * Shows the tax opt-in checkbox
 *
 * @since 1.3.3
 * @global $edd_options Array of all the EDD Options
 * @return void
 */
function edd_show_local_tax_opt_in()
{
    global $edd_options;
    if (edd_use_taxes() && isset($edd_options['tax_condition']) && $edd_options['tax_condition'] == 'local') {
        ?>
		<fieldset id="edd_tax_opt_in_fields">
			<p id="edd-tax-opt-in-wrap">
				<label for="edd_tax_opt_in"><?php 
        echo isset($edd_options['tax_location']) ? $edd_options['tax_location'] : __('Opt Into Taxes?', 'edd');
        ?>
</label>
				<input name="edd_tax_opt_in" type="checkbox" id="edd_tax_opt_in" value="1"<?php 
        checked(true, edd_local_tax_opted_in());
        ?>
/>
			</p>
		</fieldset>
<?php 
    }
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:27,代码来源:template.php

示例12: edd_ajax_add_to_cart

/**
 * Adds item to the cart via AJAX.
 *
 * @since 1.0
 * @return void
 */
function edd_ajax_add_to_cart()
{
    if (isset($_POST['download_id'])) {
        $to_add = array();
        if (isset($_POST['price_ids']) && is_array($_POST['price_ids'])) {
            foreach ($_POST['price_ids'] as $price) {
                $to_add[] = array('price_id' => $price);
            }
        }
        $items = '';
        foreach ($to_add as $options) {
            if ($_POST['download_id'] == $options['price_id']) {
                $options = array();
            }
            parse_str($_POST['post_data'], $post_data);
            if (isset($options['price_id']) && isset($post_data['edd_download_quantity_' . $options['price_id']])) {
                $options['quantity'] = absint($post_data['edd_download_quantity_' . $options['price_id']]);
            } else {
                $options['quantity'] = isset($post_data['edd_download_quantity']) ? absint($post_data['edd_download_quantity']) : 1;
            }
            $key = edd_add_to_cart($_POST['download_id'], $options);
            $item = array('id' => $_POST['download_id'], 'options' => $options);
            $item = apply_filters('edd_ajax_pre_cart_item_template', $item);
            $items .= html_entity_decode(edd_get_cart_item_template($key, $item, true), ENT_COMPAT, 'UTF-8');
        }
        $return = array('subtotal' => html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_cart_subtotal())), ENT_COMPAT, 'UTF-8'), 'total' => html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_cart_total())), ENT_COMPAT, 'UTF-8'), 'cart_item' => $items, 'cart_quantity' => html_entity_decode(edd_get_cart_quantity()));
        if (edd_use_taxes()) {
            $cart_tax = (double) edd_get_cart_tax();
            $return['tax'] = html_entity_decode(edd_currency_filter(edd_format_amount($cart_tax)), ENT_COMPAT, 'UTF-8');
        }
        echo json_encode($return);
    }
    edd_die();
}
开发者ID:upsellpl,项目名称:Easy-Digital-Downloads,代码行数:40,代码来源:ajax-functions.php

示例13: edd_process_paypal_purchase

/**
 * Process PayPal Purchase
 *
 * @since 1.0
 * @param array   $purchase_data Purchase Data
 * @return void
 */
function edd_process_paypal_purchase($purchase_data)
{
    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
        wp_die(__('Nonce verification has failed', 'edd'), __('Error', 'edd'), array('response' => 403));
    }
    // Collect payment data
    $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'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'paypal', 'status' => !empty($purchase_data['buy_now']) ? 'private' : 'pending');
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    // Check payment
    if (!$payment) {
        // Record the error
        edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
        // Problems? send back
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    } else {
        // Only send to PayPal if the pending payment is created successfully
        $listener_url = add_query_arg('edd-listener', 'IPN', home_url('index.php'));
        // Get the success url
        $return_url = add_query_arg(array('payment-confirmation' => 'paypal', 'payment-id' => $payment), get_permalink(edd_get_option('success_page', false)));
        // Get the PayPal redirect uri
        $paypal_redirect = trailingslashit(edd_get_paypal_redirect()) . '?';
        // Setup PayPal arguments
        $paypal_args = array('business' => edd_get_option('paypal_email', false), 'email' => $purchase_data['user_email'], 'first_name' => $purchase_data['user_info']['first_name'], 'last_name' => $purchase_data['user_info']['last_name'], 'invoice' => $purchase_data['purchase_key'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => edd_get_currency(), 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'cancel_return' => edd_get_failed_transaction_uri('?payment-id=' . $payment), 'notify_url' => $listener_url, 'page_style' => edd_get_paypal_page_style(), 'cbt' => get_bloginfo('name'), 'bn' => 'EasyDigitalDownloads_SP');
        if (!empty($purchase_data['user_info']['address'])) {
            $paypal_args['address1'] = $purchase_data['user_info']['address']['line1'];
            $paypal_args['address2'] = $purchase_data['user_info']['address']['line2'];
            $paypal_args['city'] = $purchase_data['user_info']['address']['city'];
            $paypal_args['country'] = $purchase_data['user_info']['address']['country'];
        }
        $paypal_extra_args = array('cmd' => '_cart', 'upload' => '1');
        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
        // Add cart items
        $i = 1;
        foreach ($purchase_data['cart_details'] as $item) {
            $item_amount = round($item['subtotal'] / $item['quantity'] - $item['discount'] / $item['quantity'], 2);
            if ($item_amount <= 0) {
                $item_amount = 0;
            }
            $paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(edd_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
            $paypal_args['quantity_' . $i] = $item['quantity'];
            $paypal_args['amount_' . $i] = $item_amount;
            if (edd_use_skus()) {
                $paypal_args['item_number_' . $i] = edd_get_download_sku($item['id']);
            }
            $i++;
        }
        // Calculate discount
        $discounted_amount = 0.0;
        if (!empty($purchase_data['fees'])) {
            $i = empty($i) ? 1 : $i;
            foreach ($purchase_data['fees'] as $fee) {
                if (floatval($fee['amount']) > '0') {
                    // this is a positive fee
                    $paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(wp_strip_all_tags($fee['label']), ENT_COMPAT, 'UTF-8'));
                    $paypal_args['quantity_' . $i] = '1';
                    $paypal_args['amount_' . $i] = edd_sanitize_amount($fee['amount']);
                    $i++;
                } else {
                    // This is a negative fee (discount)
                    $discounted_amount += abs($fee['amount']);
                }
            }
        }
        if ($discounted_amount > '0') {
            $paypal_args['discount_amount_cart'] = edd_sanitize_amount($discounted_amount);
        }
        // Add taxes to the cart
        if (edd_use_taxes()) {
            $paypal_args['tax_cart'] = edd_sanitize_amount($purchase_data['tax']);
        }
        $paypal_args = apply_filters('edd_paypal_redirect_args', $paypal_args, $purchase_data);
        // Build query
        $paypal_redirect .= http_build_query($paypal_args);
        // Fix for some sites that encode the entities
        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
        // Get rid of cart contents
        edd_empty_cart();
        // Redirect to PayPal
        wp_redirect($paypal_redirect);
        exit;
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:90,代码来源:paypal-standard.php

示例14: edd_tools_sysinfo_get


//.........这里部分代码省略.........
    $return .= 'Thousands Separator:      ' . edd_get_option('thousands_separator', ',') . "\n";
    $return = apply_filters('edd_sysinfo_after_edd_config', $return);
    // EDD pages
    $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
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:67,代码来源:tools.php

示例15: edd_display_tax_rate

/**
 * Check to see if we should show included taxes
 *
 * Some countries (notably in the EU) require included taxes to be displayed.
 *
 * @since 1.7
 * @author Daniel J Griffiths
 * @return bool
 */
function edd_display_tax_rate()
{
    $ret = edd_use_taxes() && edd_get_option('display_tax_rate', false);
    return apply_filters('edd_display_tax_rate', $ret);
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:14,代码来源:tax-functions.php


注:本文中的edd_use_taxes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。