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


PHP edd_get_cart_item_price函数代码示例

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


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

示例1: edd_get_cart_item_template

/**
 * Get Cart Item Template
 *
 * @since 1.0
 * @param int $cart_key Cart key
 * @param array $item Cart item
 * @param bool $ajax AJAX?
 * @return string Cart item
*/
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);
    $title = get_the_title($id);
    $options = !empty($item['options']) ? $item['options'] : array();
    $quantity = edd_get_cart_item_quantity($id, $options);
    $price = edd_get_cart_item_price($id, $options);
    if (!empty($options)) {
        $title .= edd_has_variable_prices($item['id']) ? ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']) : edd_get_price_name($id, $item['options']);
    }
    ob_start();
    edd_get_template_part('widget', 'cart-item');
    $item = ob_get_clean();
    $item = str_replace('{item_title}', $title, $item);
    $item = str_replace('{item_amount}', edd_currency_filter(edd_format_amount($price)), $item);
    $item = str_replace('{cart_item_id}', absint($cart_key), $item);
    $item = str_replace('{item_id}', absint($id), $item);
    $item = str_replace('{item_quantity}', absint($quantity), $item);
    $item = str_replace('{remove_url}', $remove_url, $item);
    $subtotal = '';
    if ($ajax) {
        $subtotal = edd_currency_filter(edd_format_amount(edd_get_cart_subtotal()));
    }
    $item = str_replace('{subtotal}', $subtotal, $item);
    return apply_filters('edd_cart_item', $item, $id);
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:template.php

示例2: download_checkout_item_total_function

function download_checkout_item_total_function($atts)
{
    $atts = shortcode_atts(array('id' => ''), $atts, 'download_checkout_item_total');
    global $x, $cart_array;
    if ($atts['id'] != '') {
        $id = $atts['id'];
    } else {
        $id = get_the_id();
    }
    $options = $cart_array[get_the_ID()][$x - 1]['options'];
    $price = edd_get_cart_item_price($id, $options);
    $price += edd_get_cart_item_tax($id, $options, $price);
    $price = edd_currency_filter(edd_format_amount($price));
    return $price;
}
开发者ID:Bento4Extend,项目名称:EDD-Checkout-Shortcodes,代码行数:15,代码来源:download_checkout_item_total.php

示例3: 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();
    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_get_cart_item_price($id, $options)) . '&nbsp;';
    $item .= '<span class="edd-cart-item-separator">-</span> ' . $remove . '</li>';
    return apply_filters('edd_cart_item', $item, $id);
}
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:23,代码来源:cart-template.php

示例4: edd_get_cart_item_discount_amount

/**
 * Get the discounted amount on a price
 *
 * @since 1.9
 * @param array $item Cart item array
 * @return float The discounted amount
 */
function edd_get_cart_item_discount_amount($item = array())
{
    global $edd_is_last_cart_item, $edd_flat_discount_total;
    // If we're not meeting the requirements of the $item array, return or set them
    if (empty($item) || empty($item['id'])) {
        return 0;
    }
    // Quantity is a requirement of the cart options array to determine the discounted price
    if (empty($item['quantity'])) {
        return 0;
    }
    if (!isset($item['options'])) {
        $item['options'] = array();
    }
    $amount = 0;
    $price = edd_get_cart_item_price($item['id'], $item['options']);
    $discounted_price = $price;
    // Retrieve all discounts applied to the cart
    $discounts = edd_get_cart_discounts();
    if ($discounts) {
        foreach ($discounts as $discount) {
            $code_id = edd_get_discount_id_by_code($discount);
            // Check discount exists
            if (!$code_id) {
                continue;
            }
            $reqs = edd_get_discount_product_reqs($code_id);
            $excluded_products = edd_get_discount_excluded_products($code_id);
            // Make sure requirements are set and that this discount shouldn't apply to the whole cart
            if (!empty($reqs) && edd_is_discount_not_global($code_id)) {
                // This is a product(s) specific discount
                foreach ($reqs as $download_id) {
                    if ($download_id == $item['id'] && !in_array($item['id'], $excluded_products)) {
                        $discounted_price -= $price - edd_get_discounted_amount($discount, $price);
                    }
                }
            } else {
                // This is a global cart discount
                if (!in_array($item['id'], $excluded_products)) {
                    if ('flat' === edd_get_discount_type($code_id)) {
                        /* *
                         * In order to correctly record individual item amounts, global flat rate discounts
                         * are distributed across all cart items. The discount amount is divided by the number
                         * of items in the cart and then a portion is evenly applied to each cart item
                         */
                        $items_subtotal = 0.0;
                        $cart_items = edd_get_cart_contents();
                        foreach ($cart_items as $cart_item) {
                            if (!in_array($cart_item['id'], $excluded_products)) {
                                $item_price = edd_get_cart_item_price($cart_item['id'], $cart_item['options']);
                                $items_subtotal += $item_price * $cart_item['quantity'];
                            }
                        }
                        $subtotal_percent = $price * $item['quantity'] / $items_subtotal;
                        $code_amount = edd_get_discount_amount($code_id);
                        $discounted_amount = $code_amount * $subtotal_percent;
                        $discounted_price -= $discounted_amount;
                        $edd_flat_discount_total += round($discounted_amount, edd_currency_decimal_filter());
                        if ($edd_is_last_cart_item && $edd_flat_discount_total < $code_amount) {
                            $adjustment = $code_amount - $edd_flat_discount_total;
                            $discounted_price -= $adjustment;
                        }
                    } else {
                        $discounted_price -= $price - edd_get_discounted_amount($discount, $price);
                    }
                }
            }
        }
        $amount = $price - apply_filters('edd_get_cart_item_discounted_amount', $discounted_price, $discounts, $item, $price);
        if ('flat' !== edd_get_discount_type($code_id)) {
            $amount = $amount * $item['quantity'];
        }
    }
    return $amount;
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:82,代码来源:discount-functions.php

示例5: edd_get_cart_item_quantity

    echo edd_get_cart_item_quantity($item['id'], $item['options']);
    ?>
" />

				<input type="hidden" name="edd-cart-downloads[]" value="<?php 
    echo $item['id'];
    ?>
" />
				<input type="hidden" name="edd-cart-download-<?php 
    echo $template_args['key'];
    ?>
-options" value="<?php 
    echo esc_attr(serialize($item['options']));
    ?>
" />
			</label>
		<?php 
}
?>
	</div>
	<div class="checkout__price one-seventh medium-one-half small-one-fifth">
		<?php 
echo esc_html(edd_currency_filter(edd_format_amount(edd_get_cart_item_price($item['id'], $item['options']) * edd_get_cart_item_quantity($item['id'], $item['options']))));
?>
		<a href="<?php 
echo esc_url(edd_remove_item_url($template_args['key']));
?>
" class="button--naked checkout__cancel edd_cart_remove_item_btn"><span class="text-icon">&#xf00d;</a>
	</div>
</li>
<?php 
开发者ID:apsolut,项目名称:Yoast-theme-public,代码行数:31,代码来源:checkout-item.php

示例6: edd_get_cart_content_details

/**
 * Get Cart Content Details
 *
 * Retrieves the cart contnet details.
 *
 * @access      public
 * @since       1.0
 * @return      array
*/
function edd_get_cart_content_details()
{
    $cart_items = edd_get_cart_contents();
    $details = array();
    if ($cart_items) {
        foreach ($cart_items as $key => $item) {
            $details[$key] = array('name' => get_the_title($item['id']), 'id' => $item['id'], 'item_number' => $item, 'price' => edd_get_cart_item_price($item['id'], $item['options']), 'quantity' => 1);
        }
    }
    if (!empty($details)) {
        return $details;
    }
    return false;
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:23,代码来源:functions.php

示例7: 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;
}
开发者ID:unclebrain,项目名称:appthemer-crowdfunding,代码行数:29,代码来源:checkout.php

示例8: edd_get_cart_discounted_amount

/**
 * Retrieves the total discounted amount on the cart
 *
 * @since 1.4.1
 * @param array $discounts Discount codes
 * @return float $discounted_amount Total discounted amount
 */
function edd_get_cart_discounted_amount($discounts = false)
{
    if (empty($discounts)) {
        $discounts = edd_get_cart_discounts();
    }
    // Setup the array of discounts
    if (!empty($_POST['edd-discount']) && empty($discounts)) {
        // Check for a posted discount
        $posted_discount = isset($_POST['edd-discount']) ? trim($_POST['edd-discount']) : false;
        if ($posted_discount) {
            $discounts = array();
            $discounts[] = $posted_discount;
        }
    }
    // Return 0.00 if no discounts present
    if (empty($discounts)) {
        return 0.0;
    }
    $subtotal = edd_get_cart_subtotal($tax = false);
    $amounts = array();
    $discounted_items = array();
    foreach ($discounts as $discount) {
        $code_id = edd_get_discount_id_by_code($discount);
        $reqs = edd_get_discount_product_reqs($code_id);
        // Make sure requirements are set and that this discount shouldn't apply to the whole cart
        if (!empty($reqs) && edd_is_discount_not_global($code_id)) {
            // This is a product(s) specific discount
            $condition = edd_get_discount_product_condition($code_id);
            $cart_items = edd_get_cart_contents();
            foreach ($reqs as $download_id) {
                if (edd_item_in_cart($download_id)) {
                    $cart_key = edd_get_item_position_in_cart($download_id);
                    $price = edd_get_cart_item_price($download_id, $cart_items[$cart_key]['options']);
                    $amount = edd_get_discounted_amount($discount, $price);
                    $discounted_items[] = $price - $amount;
                }
            }
        } else {
            // This is a global cart discount
            $subtotal = edd_get_cart_subtotal();
            $amount = edd_get_discounted_amount($discount, $subtotal);
            $amounts[] = $subtotal - $amount;
        }
    }
    // Add up the total amount
    $discounted_amount = 0.0;
    $item_discount = array_sum($discounted_items);
    $global_discount = array_sum($amounts);
    $discounted_amount += $item_discount;
    $discounted_amount += $global_discount;
    return apply_filters('edd_get_cart_discounted_amount', edd_sanitize_amount($discounted_amount));
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:59,代码来源:discount-functions.php

示例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 = '&nbsp;&ndash;&nbsp;';
        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);
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:functions.php

示例10: get_the_post_thumbnail

        if (current_theme_supports('post-thumbnails')) {
            if (has_post_thumbnail($item['id'])) {
                echo '<div class="edd_cart_item_image">';
                echo get_the_post_thumbnail($item['id'], apply_filters('edd_checkout_image_size', array(25, 25)));
                echo '</div>';
            }
        }
        $item_title = get_the_title($item['id']);
        if (!empty($item['options'])) {
            $item_title .= ' - ' . edd_get_price_name($item['id'], $item['options']);
        }
        echo '<span class="edd_checkout_cart_item_title">' . esc_html($item_title) . '</span>';
        ?>
					</td>
					<td class="edd_cart_item_price"><?php 
        echo esc_html(edd_currency_filter(edd_get_cart_item_price($item['id'], $item['options'])));
        ?>
</td>
					<td class="edd_cart_actions"><a href="<?php 
        echo esc_url(edd_remove_item_url($key, $post));
        ?>
"><?php 
        _e('remove', 'edd');
        ?>
</a></td>
					<?php 
        do_action('edd_checkout_table_body_last', $item);
        ?>
				</tr>
			<?php 
    }
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:checkout_cart.php

示例11: 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 = '&nbsp;&ndash;&nbsp;';
             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;
 }
开发者ID:gelther,项目名称:EDD-Sale-Price,代码行数:55,代码来源:class-eddsp-sale-price.php

示例12: edd_wl_get_list_total

/**
 * Total price of items in wish list
 *
 * Used on front end and also admin
 * @since 1.0
 * @param $list_id ID of list
 * @todo  update total as items are removed from list via ajax
 */
function edd_wl_get_list_total($list_id)
{
    // get contents of cart
    $list_items = get_post_meta($list_id, 'edd_wish_list', true);
    $total = array();
    if ($list_items) {
        foreach ($list_items as $item) {
            $item_price = edd_get_cart_item_price($item['id'], $item['options']);
            $item_price = round($item_price, 2);
            $total[] = $item_price;
        }
    }
    // add up values
    $total = array_sum($total);
    $total = esc_html(edd_currency_filter(edd_format_amount($total)));
    return apply_filters('edd_wl_list_total', $total);
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:25,代码来源:functions.php

示例13: eddpdfi_pdf_template_vat


//.........这里部分代码省略.........
    $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);
        $eddpdfi_pdf->SetFillColor($colors['header'][0], $colors['header'][1], $colors['header'][2]);
        $eddpdfi_pdf->SetFont($fontb, '', 10);
        $eddpdfi_pdf->Cell(140, 8, __('Invoice Totals', 'eddpdfi'), 1, 2, 'C', true);
        $eddpdfi_pdf->Ln(0.2);
        $eddpdfi_pdf->SetX(61);
        if (edd_use_taxes()) {
            //$taxrate = (edd_get_payment_amount( $eddpdfi_payment->ID ) - round(edd_get_payment_subtotal( $eddpdfi_payment->ID ))) / round(edd_get_payment_subtotal( $eddpdfi_payment->ID )) * 100;
            switch ($eddpdfi_buyer_info['address']['country']) {
                case 'BE':
                    $taxrate = '21%';
                    break;
                case 'BG':
                    $taxrate = '20%';
                    break;
                case 'CZ':
                    $taxrate = '21%';
开发者ID:brandsondigital,项目名称:mashshare-theme,代码行数:67,代码来源:vat-template.php

示例14: edd_downloads_upgrade_to_cart

function edd_downloads_upgrade_to_cart($item)
{
    $post_data = urldecode($_REQUEST['post_data']);
    $post_data_formated = array();
    if (strstr($post_data, "upgrade_license") && strstr($post_data, "upgrade_product_to")) {
        $post_data_split = explode("&", $post_data);
        foreach ($post_data_split as $data_split) {
            $data_array = explode("=", $data_split);
            $post_data_formated[$data_array[0]] = $data_array[1];
        }
    }
    if (isset($post_data_formated['upgrade_license']) && isset($post_data_formated['upgrade_product_to'])) {
        $price_id = isset($item['options']['price_id']) ? $item['options']['price_id'] : 0;
        $download_files = edd_get_download_files($post_data_formated['upgrade_product_to'], $price_id);
        $post_meta = get_post_meta(absint($post_data_formated['upgrade_license']), '_edd_sl_download_id', true);
        $old_price_id = get_post_meta(absint($post_data_formated['upgrade_license']), '_edd_sl_download_price_id', true);
        $old_download_file = edd_get_download_files($post_meta, $old_price_id);
        $item['upgrade'] = array();
        $item['upgrade']['old_product'] = absint($post_data_formated['old_product']);
        $item['upgrade']['new_attachment_id'] = isset($download_files[0]['attachment_id']) ? absint($download_files[0]['attachment_id']) : 0;
        $item['upgrade']['old_attachment_id'] = isset($old_download_file[0]['attachment_id']) ? absint($old_download_file[0]['attachment_id']) : 0;
        $item['upgrade']['upgrade_license'] = absint($post_data_formated['upgrade_license']);
        $item['upgrade']['upgrade_product_to'] = absint($post_data_formated['upgrade_product_to']);
        if (isset($item['options']) && !empty($item['options'])) {
            $item['upgrade']['options'] = $item['options'];
        }
        $old_product_price = edd_get_cart_item_price(absint($post_data_formated['old_product']), $item['options']);
        $new_product_price = edd_get_cart_item_price(absint($post_data_formated['upgrade_product_to']), $item['options']);
        $item['upgrade']['upgrade_price'] = edd_format_amount($new_product_price - $old_product_price);
        //edd_get_cart_item_price( absint($post_data_formated['upgrade_product_to']), $item['options'] );
        $payment_id_lic = get_post_meta($post_data_formated['upgrade_license'], '_edd_sl_payment_id', true);
        $item['upgrade']['upgrade_product_used'] = 0;
        $session = edd_get_purchase_session();
        $payment_key = edd_get_payment_key(absint($payment_id_lic));
        $session['purchase_key'] = $payment_key;
        edd_set_purchase_session($session);
        EDD()->session->set('upgrade_license', $payment_key);
    }
    return $item;
}
开发者ID:jomsocial,项目名称:eddDownloads,代码行数:40,代码来源:edd_downloads.php

示例15: edd_get_cart_content_details

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


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