本文整理汇总了PHP中wpsc_cart_tax函数的典型用法代码示例。如果您正苦于以下问题:PHP wpsc_cart_tax函数的具体用法?PHP wpsc_cart_tax怎么用?PHP wpsc_cart_tax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpsc_cart_tax函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _wpsc_get_checkout_info
/**
* Get replacement elements for country and region fields on the checkout form
*
* Note: extracted from the wpsc_change_tax function in ajax.php as of version 3.8.13.3
*
* @since 3.8.14
* @access private
* @return array checkout information
*/
function _wpsc_get_checkout_info()
{
global $wpsc_cart;
// Checkout info is what we will return to the AJAX client
$checkout_info = array();
// start with items that have no dependencies
$checkout_info['delivery_country'] = wpsc_get_customer_meta('shippingcountry');
$checkout_info['billing_country'] = wpsc_get_customer_meta('billingcountry');
$checkout_info['country_name'] = wpsc_get_country($checkout_info['delivery_country']);
$checkout_info['lock_tax'] = get_option('lock_tax');
// TODO: this is set anywhere, probably deprecated
$checkout_info['needs_shipping_recalc'] = wpsc_cart_need_to_recompute_shipping_quotes();
$checkout_info['shipping_keys'] = array();
foreach ($wpsc_cart->cart_items as $key => $cart_item) {
$checkout_info['shipping_keys'][$key] = wpsc_currency_display($cart_item->shipping);
}
if (!$checkout_info['needs_shipping_recalc']) {
$wpsc_cart->update_location();
$wpsc_cart->get_shipping_method();
$wpsc_cart->get_shipping_option();
if ($wpsc_cart->selected_shipping_method != '') {
$wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
}
$tax = $wpsc_cart->calculate_total_tax();
$total = wpsc_cart_total();
$total_input = wpsc_cart_total(false);
if ($wpsc_cart->coupons_amount >= $total_input && !empty($wpsc_cart->coupons_amount)) {
$total = 0;
}
if ($wpsc_cart->total_price < 0) {
$wpsc_cart->coupons_amount += $wpsc_cart->total_price;
$wpsc_cart->total_price = null;
$wpsc_cart->calculate_total_price();
}
$cart_widget = _wpsc_ajax_get_cart(false);
if (isset($cart_widget['widget_output']) && !empty($cart_widget['widget_output'])) {
$checkout_info['widget_output'] = $cart_widget['widget_output'];
}
$checkout_info['cart_shipping'] = wpsc_cart_shipping();
$checkout_info['tax'] = $tax;
$checkout_info['display_tax'] = wpsc_cart_tax();
$checkout_info['total'] = $total;
$checkout_info['total_input'] = $total_input;
}
return apply_filters('wpsc_ajax_checkout_info', $checkout_info);
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:55,代码来源:wpsc-checkout-ajax.php
示例2: wpsc_cart_tax
?>
</table>
<?php
}
?>
<table class="productcart">
<tr class="total_price total_tax">
<td colspan="3">
<?php
echo TXT_WPSC_TAX;
?>
</td>
<td colspan="2">
<span id="checkout_tax" class="pricedisplay checkout-tax"><?php
echo wpsc_cart_tax();
?>
</span>
</td>
</tr>
<?php
if (wpsc_uses_coupons() && wpsc_coupon_amount(false) > 0) {
?>
<tr class="total_price">
<td colspan="3">
<?php
echo TXT_WPSC_COUPONS;
?>
</td>
<td colspan="2">
<span id="coupons_amount" class="pricedisplay"><?php
开发者ID:papayalabs,项目名称:htdocs,代码行数:31,代码来源:shopping_cart_page.php
示例3: wpsc_change_tax
//.........这里部分代码省略.........
$wpsc_selected_region = null;
}
if (isset($_POST['shipping_country'])) {
$wpsc_delivery_country = $wpdb->escape($_POST['shipping_country']);
$_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
}
if (isset($_POST['shipping_region'])) {
$wpsc_delivery_region = absint($_POST['shipping_region']);
$_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
}
$check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $wpsc_delivery_region . "' LIMIT 1");
if ($wpsc_delivery_country != $check_country_code) {
$wpsc_delivery_region = null;
}
$wpsc_cart->update_location();
$wpsc_cart->get_shipping_method();
$wpsc_cart->get_shipping_option();
if ($wpsc_cart->selected_shipping_method != '') {
$wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
}
$tax = $wpsc_cart->calculate_total_tax();
$total = wpsc_cart_total();
ob_start();
$cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder', $wpsc_theme_path . WPSC_THEME_DIR);
include_once $cur_wpsc_theme_folder . "/cart_widget.php";
$output = ob_get_contents();
ob_end_clean();
//exit("/*<pre>".print_r($wpsc_cart,true)."</pre>*/");
$output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
if (get_option('lock_tax') == 1) {
//echo "jQuery('#region').val(".$_SESSION['wpsc_delivery_region']."); \n";
echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n";
if ($_SESSION['wpsc_delivery_country'] == 'US' && get_option('lock_tax') == 1) {
//exit('<pre>'.print_r($_SESSION, true).'</pre>');
$output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']);
// echo 'jQuery("#change_country").append(\''.$output.'\');\n\r';
$output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
echo "jQuery('#region').remove();\n\r";
echo "jQuery('#change_country').append(\"" . $output . "\");\n\r";
}
}
foreach ($wpsc_cart->cart_items as $key => $cart_item) {
echo "jQuery('#shipping_{$key}').html(\"" . $wpsc_cart->process_as_currency($cart_item->shipping) . "\");\n\r";
}
echo "jQuery('#checkout_shipping').html(\"" . wpsc_cart_shipping() . "\");\n\r";
echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
if (get_option('lock_tax') == 1) {
echo "jQuery('.shipping_country').val('" . $_SESSION['wpsc_delivery_country'] . "') \n";
$sql = "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_selected_country'] . "'";
$country_name = $wpdb->get_var($sql);
echo "jQuery('.shipping_country_name').html('" . $country_name . "') \n";
}
$form_selected_country = null;
$form_selected_region = null;
$onchange_function = null;
if ($_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
$form_selected_country = $wpsc_selected_country;
$form_selected_region = $wpsc_selected_region;
$onchange_function = 'set_billing_country';
$title = 'billingregion';
} else {
if ($_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
$form_selected_country = $wpsc_delivery_country;
$form_selected_region = $wpsc_delivery_region;
$onchange_function = 'set_shipping_country';
$title = 'shippingregion';
}
}
if ($form_selected_country != null && $onchange_function != null) {
$region_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $form_selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A);
if ($region_list != null) {
$output = "<select title='{$title}' name='collected_data[" . $form_id . "][1]' class='current_region' onchange='{$onchange_function}(\"region_country_form_{$form_id}\", \"{$form_id}\");'>\n\r";
foreach ($region_list as $region) {
if ($form_selected_region == $region['id']) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$output .= " <option value='" . $region['id'] . "' {$selected}>" . htmlspecialchars($region['name']) . "</option>\n\r";
}
$output .= "</select>\n\r";
$output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
echo "jQuery('#region_select_{$form_id}').html(\"" . $output . "\");\n\r";
} else {
if (get_option('lock_tax') == 1) {
echo "jQuery('#region').hide();";
}
echo "jQuery('#region_select_{$form_id}').html('');\n\r";
}
}
if ($tax > 0) {
echo "jQuery(\"tr.total_tax\").show();\n\r";
} else {
echo "jQuery(\"tr.total_tax\").hide();\n\r";
}
echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpsc_cart_tax() . "</span>\");\n\r";
echo "jQuery('#checkout_total').html(\"<span class='pricedisplay'>{$total}</span><input id='shopping_cart_total_price' type='hidden' value='{$total}' />\");\n\r";
//echo "\n\r/*\n\r{$wpsc_cart->tax_percentage}\n\r*/\n\r";
exit;
}
开发者ID:alx,项目名称:SBek-Arak,代码行数:101,代码来源:ajax.functions.php
示例4: wpsc_display_tax_label
</div>
<?php
return;
endif;
?>
</table>
<?php endif; ?>
<table class="productcart">
<tr class="total_price total_tax">
<td colspan="3">
<?php echo wpsc_display_tax_label(true); ?>
</td>
<td colspan="2">
<span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
</td>
</tr>
<?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
<tr class="total_price">
<td colspan="3">
<?php echo __('Discount', 'wpsc'); ?>
</td>
<td colspan="2">
<span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
</td>
</tr>
<?php endif ?>
开发者ID:nerdfiles,项目名称:sideshowtramps.com,代码行数:28,代码来源:shopping_cart_page.php
示例5: get_shipping_method_js_vars
private function get_shipping_method_js_vars()
{
global $wpsc_cart;
$js_var = array('subtotal' => (double) $wpsc_cart->calculate_subtotal(), 'shipping' => array(), 'tax' => wpsc_is_tax_enabled() && !wpsc_is_tax_included() ? (double) wpsc_cart_tax(false) : 0, 'discount' => wpsc_coupon_amount(false) > 0 ? wpsc_coupon_amount(false) : 0);
foreach ($this->shipping_calculator->sorted_quotes as $module_name => $quotes) {
foreach ($quotes as $option => $cost) {
$id = $this->shipping_calculator->ids[$module_name][$option];
$js_var['shipping'][$id] = $cost;
}
}
$currency = new WPSC_Country(get_option('currency_type'));
$currency_code = $currency->get_currency_code();
$isocode = $currency->get_isocode();
$without_fractions = in_array($currency_code, WPSC_Payment_Gateways::currencies_without_fractions());
$decimals = $without_fractions ? 0 : 2;
$decimals = apply_filters('wpsc_modify_decimals', $decimals, $isocode);
$decimal_separator = apply_filters('wpsc_format_currency_decimal_separator', wpsc_get_option('decimal_separator'), $isocode);
$thousands_separator = apply_filters('wpsc_format_currency_thousands_separator', wpsc_get_option('thousands_separator'), $isocode);
$symbol = apply_filters('wpsc_format_currency_currency_symbol', $currency->get_currency_symbol());
$sign_location = get_option('currency_sign_location');
$js_var['formatter'] = array('currency_code' => $currency_code, 'without_fractions' => $without_fractions, 'decimals' => $decimals, 'decimal_separator' => $decimal_separator, 'thousands_separator' => $thousands_separator, 'symbol' => $symbol, 'sign_location' => $sign_location);
return $js_var;
}
开发者ID:androidprojectwork,项目名称:WP-e-Commerce,代码行数:23,代码来源:checkout.php
示例6: wpsc_change_tax
//.........这里部分代码省略.........
}
if (isset($_POST['shipping_region'])) {
$wpsc_delivery_region = absint($_POST['shipping_region']);
$_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
}
$check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $wpsc_delivery_region . "' LIMIT 1");
if ($wpsc_delivery_country != $check_country_code) {
$wpsc_delivery_region = null;
}
$wpsc_cart->update_location();
$wpsc_cart->get_shipping_method();
$wpsc_cart->get_shipping_option();
if ($wpsc_cart->selected_shipping_method != '') {
$wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
}
$tax = $wpsc_cart->calculate_total_tax();
$total = wpsc_cart_total();
$total_input = wpsc_cart_total(false);
if ($wpsc_cart->coupons_amount >= wpsc_cart_total() && !empty($wpsc_cart->coupons_amount)) {
$total = 0;
}
if ($wpsc_cart->total_price < 0) {
$wpsc_cart->coupons_amount += $wpsc_cart->total_price;
$wpsc_cart->total_price = null;
$wpsc_cart->calculate_total_price();
}
ob_start();
include_once wpsc_get_template_file_path('wpsc-cart_widget.php');
$output = ob_get_contents();
ob_end_clean();
$output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
if (get_option('lock_tax') == 1) {
echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n";
if ($_SESSION['wpsc_delivery_country'] == 'US' && get_option('lock_tax') == 1) {
$output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']);
$output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
echo "jQuery('#region').remove();\n\r";
echo "jQuery('#change_country').append(\"" . $output . "\");\n\r";
}
}
foreach ($wpsc_cart->cart_items as $key => $cart_item) {
echo "jQuery('#shipping_{$key}').html(\"" . wpsc_currency_display($cart_item->shipping) . "\");\n\r";
}
echo "jQuery('#checkout_shipping').html(\"" . wpsc_cart_shipping() . "\");\n\r";
echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
if (get_option('lock_tax') == 1) {
echo "jQuery('.shipping_country').val('" . $_SESSION['wpsc_delivery_country'] . "') \n";
$sql = "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_selected_country'] . "'";
$country_name = $wpdb->get_var($sql);
echo "jQuery('.shipping_country_name').html('" . $country_name . "') \n";
}
$form_selected_country = null;
$form_selected_region = null;
$onchange_function = null;
if ($_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
$form_selected_country = $wpsc_selected_country;
$form_selected_region = $wpsc_selected_region;
$onchange_function = 'set_billing_country';
} else {
if ($_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
$form_selected_country = $wpsc_delivery_country;
$form_selected_region = $wpsc_delivery_region;
$onchange_function = 'set_shipping_country';
}
}
if ($form_selected_country != null && $onchange_function != null) {
$region_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $form_selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A);
if ($region_list != null) {
$title = empty($_POST['billing_country']) ? 'shippingstate' : 'billingstate';
$output = "<select name='collected_data[" . $form_id . "][1]' class='current_region' onchange='{$onchange_function}(\"region_country_form_{$form_id}\", \"{$form_id}\");' title='" . $title . "'>\n\r";
foreach ($region_list as $region) {
if ($form_selected_region == $region['id']) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$output .= " <option value='" . $region['id'] . "' {$selected}>" . htmlspecialchars($region['name']) . "</option>\n\r";
}
$output .= "</select>\n\r";
$output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
echo "jQuery('#region_select_{$form_id}').html(\"" . $output . "\");\n\r";
echo "\n\t\t\t\tvar wpsc_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpsc_checkout_table').attr('class');\n\t\t\t\twpsc_checkout_table_selector = wpsc_checkout_table_selector.replace(' ','.');\n\t\t\t\twpsc_checkout_table_selector = '.'+wpsc_checkout_table_selector;\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.billing_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.shipping_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .billing_region').parent().parent().hide();\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .shipping_region').parent().parent().hide();\n\t\t\t";
} else {
if (get_option('lock_tax') == 1) {
echo "jQuery('#region').hide();";
}
echo "jQuery('#region_select_{$form_id}').html('');\n\r";
echo "\n\t\t\t\tvar wpsc_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpsc_checkout_table').attr('class');\n\t\t\t\twpsc_checkout_table_selector = wpsc_checkout_table_selector.replace(' ','.');\n\t\t\t\twpsc_checkout_table_selector = '.'+wpsc_checkout_table_selector;\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.billing_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.shipping_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .billing_region').parent().parent().show();\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .shipping_region').parent().parent().show();\n\t\t\t";
}
}
if ($tax > 0) {
echo "jQuery(\"tr.total_tax\").show();\n\r";
} else {
echo "jQuery(\"tr.total_tax\").hide();\n\r";
}
echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpsc_cart_tax() . "</span>\");\n\r";
echo "jQuery('#checkout_total').html(\"{$total}<input id='shopping_cart_total_price' type='hidden' value='{$total_input}' />\");\n\r";
echo "if(jQuery(\"#shippingSameBilling\").is(\":checked\")) wpsc_shipping_same_as_billing();";
exit;
}
开发者ID:hornet9,项目名称:Morato,代码行数:101,代码来源:ajax.functions.php
示例7: get_tax
protected function get_tax()
{
return wpsc_cart_tax(false);
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:4,代码来源:cart-item-table.php
示例8: wpsc_change_tax
/**
* wpsc_change_tax function, used through ajax and in normal page loading.
* No parameters, returns nothing
*/
function wpsc_change_tax()
{
global $wpdb, $wpsc_cart;
$form_id = absint($_POST['form_id']);
$wpsc_selected_country = $wpsc_cart->selected_country;
$wpsc_selected_region = $wpsc_cart->selected_region;
$wpsc_delivery_country = $wpsc_cart->delivery_country;
$wpsc_delivery_region = $wpsc_cart->delivery_region;
$previous_country = wpsc_get_customer_meta('billingcountry');
global $wpdb, $user_ID, $wpsc_customer_checkout_details;
if (isset($_POST['billing_country'])) {
$wpsc_selected_country = $_POST['billing_country'];
wpsc_update_customer_meta('billingcountry', $wpsc_selected_country);
}
if (isset($_POST['billing_region'])) {
$wpsc_selected_region = absint($_POST['billing_region']);
wpsc_update_customer_meta('billingregion', $wpsc_selected_region);
}
$check_country_code = WPSC_Countries::country_id(wpsc_get_customer_meta('billing_region'));
if (wpsc_get_customer_meta('billingcountry') != $check_country_code) {
$wpsc_selected_region = null;
}
if (isset($_POST['shipping_country'])) {
$wpsc_delivery_country = $_POST['shipping_country'];
wpsc_update_customer_meta('shippingcountry', $wpsc_delivery_country);
}
if (isset($_POST['shipping_region'])) {
$wpsc_delivery_region = absint($_POST['shipping_region']);
wpsc_update_customer_meta('shippingregion', $wpsc_delivery_region);
}
$check_country_code = WPSC_Countries::country_id($wpsc_delivery_region);
if ($wpsc_delivery_country != $check_country_code) {
$wpsc_delivery_region = null;
}
$wpsc_cart->update_location();
$wpsc_cart->get_shipping_method();
$wpsc_cart->get_shipping_option();
if ($wpsc_cart->selected_shipping_method != '') {
$wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
}
$tax = $wpsc_cart->calculate_total_tax();
$total = wpsc_cart_total();
$total_input = wpsc_cart_total(false);
if ($wpsc_cart->coupons_amount >= $total_input && !empty($wpsc_cart->coupons_amount)) {
$total = 0;
}
if ($wpsc_cart->total_price < 0) {
$wpsc_cart->coupons_amount += $wpsc_cart->total_price;
$wpsc_cart->total_price = null;
$wpsc_cart->calculate_total_price();
}
$delivery_country = wpsc_get_customer_meta('shipping_country');
$output = _wpsc_ajax_get_cart(false);
$output = $output['widget_output'];
$json_response = array();
global $wpsc_checkout;
if (empty($wpsc_checkout)) {
$wpsc_checkout = new wpsc_checkout();
}
$json_response['delivery_country'] = esc_js($delivery_country);
$json_response['billing_country'] = esc_js($wpsc_selected_country);
$json_response['widget_output'] = $output;
$json_response['shipping_keys'] = array();
$json_response['cart_shipping'] = wpsc_cart_shipping();
$json_response['form_id'] = $form_id;
$json_response['tax'] = $tax;
$json_response['display_tax'] = wpsc_cart_tax();
$json_response['total'] = $total;
$json_response['total_input'] = $total_input;
$json_response['lock_tax'] = get_option('lock_tax');
$json_response['country_name'] = wpsc_get_country($delivery_country);
if ('US' == $delivery_country || 'CA' == $delivery_country) {
$output = wpsc_shipping_region_list($delivery_country, wpsc_get_customer_meta('shipping_region'));
$output = str_replace(array("\n", "\r"), '', $output);
$json_response['shipping_region_list'] = $output;
}
foreach ($wpsc_cart->cart_items as $key => $cart_item) {
$json_response['shipping_keys'][$key] = wpsc_currency_display($cart_item->shipping);
}
$form_selected_country = null;
$form_selected_region = null;
$onchange_function = null;
if (!empty($_POST['billing_country']) && $_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
$form_selected_country = $wpsc_selected_country;
$form_selected_region = $wpsc_selected_region;
$onchange_function = 'set_billing_country';
} else {
if (!empty($_POST['shipping_country']) && $_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
$form_selected_country = $wpsc_delivery_country;
$form_selected_region = $wpsc_delivery_region;
$onchange_function = 'set_shipping_country';
}
}
if ($form_selected_country != null && $onchange_function != null) {
$checkoutfields = 'set_shipping_country' == $onchange_function;
$region_list = wpsc_country_region_list($form_id, false, $form_selected_country, $form_selected_region, $form_id, $checkoutfields);
//.........这里部分代码省略.........
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:101,代码来源:ajax.php
示例9: Usecase
function Usecase($separator, $sessionid, $fromcheckout)
{
global $wpdb, $wpsc_cart;
$purchase_log_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = %s LIMIT 1", $sessionid);
$purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
$cart_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchase_log[0]['id']);
$wp_cart = $wpdb->get_results($cart_sql, ARRAY_A);
$merchant_id = get_option('google_id');
$merchant_key = get_option('google_key');
$server_type = get_option('google_server_type');
$currency = get_option('google_cur');
$transact_url = get_option('transact_url');
$returnURL = $transact_url . $separator . "sessionid=" . $sessionid . "&gateway=google";
$cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
$cart->SetContinueShoppingUrl($returnURL);
$cart->SetEditCartUrl(get_option('shopping_cart_url'));
//google prohibited items not implemented
$currency_converter = new CURRENCYCONVERTER();
$currency_code = $wpdb->get_results("SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
$local_currency_code = $currency_code[0]['code'];
$google_curr = get_option('google_cur');
$currentcy_rate = 1;
if ($google_curr != $local_currency_code) {
$currentcy_rate = $currency_converter->convert(1, $local_currency_code, $google_curr);
}
while (wpsc_have_cart_items()) {
wpsc_the_cart_item();
$google_currency_productprice = $currentcy_rate * (wpsc_cart_item_price(false) / wpsc_cart_item_quantity());
$cart_item = new GoogleItem(wpsc_cart_item_name(), '', wpsc_cart_item_quantity(), $google_currency_productprice);
$cart->AddItem($cart_item);
}
//If there are coupons applied add coupon as a product with negative price
if ($wpsc_cart->coupons_amount > 0) {
$google_currency_productprice = $currentcy_rate * $wpsc_cart->coupons_amount;
$coupon = new GoogleItem('Discount', 'Discount Price', 1, '-' . $google_currency_productprice);
$cart->AddItem($coupon);
}
$shipping_country = $purchase_log[0]['shipping_country'];
$shipping_region = $purchase_log[0]['shipping_region'];
if ($shipping_country == "UK") {
$shipping_country = "GB";
}
// Add shipping options
if (wpsc_uses_shipping()) {
$shipping_name = ucfirst($wpsc_cart->selected_shipping_method) . " - " . $wpsc_cart->selected_shipping_option;
if ($shipping_name == "") {
$shipping_name = "Calculated";
}
$shipping = new GoogleFlatRateShipping($shipping_name, $wpsc_cart->calculate_total_shipping() * $currentcy_rate);
if (!empty($shipping_country)) {
$shipping_filter = new GoogleShippingFilters();
if (!empty($shipping_region) && is_numeric($shipping_region)) {
$shipping_filter->AddAllowedPostalArea($shipping_country, wpsc_get_state_by_id($shipping_region, "code"));
$shipping_filter->AddAllowedStateArea(wpsc_get_state_by_id($shipping_region, "code"));
} else {
$shipping_filter->AddAllowedPostalArea($shipping_country);
}
$shipping->AddShippingRestrictions($shipping_filter);
}
$cart->AddShipping($shipping);
}
// Add tax rules
if (!empty($shipping_country)) {
$tax_rule = new GoogleDefaultTaxRule(wpsc_cart_tax(false) / $wpsc_cart->calculate_subtotal());
$tax_rule->AddPostalArea($shipping_country);
$cart->AddDefaultTaxRules($tax_rule);
}
// Display Google Checkout button
if (get_option('google_button_size') == '0') {
$google_button_size = 'BIG';
} elseif (get_option('google_button_size') == '1') {
$google_button_size = 'MEDIUM';
} elseif (get_option('google_button_size') == '2') {
$google_button_size = 'SMALL';
}
echo $cart->CheckoutButtonCode($google_button_size);
}
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:77,代码来源:GoogleCheckout-XML.php
注:本文中的wpsc_cart_tax函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论