本文整理汇总了PHP中wpsc_cart_total函数的典型用法代码示例。如果您正苦于以下问题:PHP wpsc_cart_total函数的具体用法?PHP wpsc_cart_total怎么用?PHP wpsc_cart_total使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpsc_cart_total函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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_total
</tr>
<?php
}
?>
<tr class='total_price'>
<td colspan='3'>
<?php
echo TXT_WPSC_TOTALPRICE;
?>
</td>
<td colspan='2'>
<span id='checkout_total' class="pricedisplay checkout-total"><?php
echo wpsc_cart_total();
?>
</span>
</td>
</tr>
</table>
<?php
do_action('wpsc_before_form_of_shopping_cart');
?>
<form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
<?php
开发者ID:papayalabs,项目名称:htdocs,代码行数:31,代码来源:shopping_cart_page.php
示例3: 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, $wpsc_theme_path;
$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 = $_SESSION['wpsc_selected_country'];
if (isset($_POST['billing_country'])) {
$wpsc_selected_country = $wpdb->escape($_POST['billing_country']);
$_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
}
if (isset($_POST['billing_region'])) {
$wpsc_selected_region = absint($_POST['billing_region']);
$_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
}
//if(!wpsc_has_shipping_form()) {
// $_POST['shipping_country'] = $wpsc_selected_country;
// $_POST['shipping_region'] = $wpsc_selected_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` = '" . $_SESSION['wpsc_selected_region'] . "' LIMIT 1");
if ($_SESSION['wpsc_selected_country'] != $check_country_code) {
$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) {
//.........这里部分代码省略.........
开发者ID:alx,项目名称:SBek-Arak,代码行数:101,代码来源:ajax.functions.php
示例4: __
<?php echo __('Discount', 'wpsc'); ?>
</td>
<td colspan="2">
<span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
</td>
</tr>
<?php endif ?>
<tr class='total_price'>
<td colspan='3'>
<?php echo __('Total Price', 'wpsc'); ?>
</td>
<td colspan='2'>
<span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
</td>
</tr>
</table>
<?php do_action('wpsc_before_form_of_shopping_cart'); ?>
<form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
<?php
/**
* Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
*/
?>
开发者ID:nerdfiles,项目名称:sideshowtramps.com,代码行数:31,代码来源:shopping_cart_page.php
示例5: paypal_processingfunctions
//.........这里部分代码省略.........
$nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType . "&ReturnUrl=" . $returnURL . "&CANCELURL=" . $cancelURL . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
/* Make the call to PayPal to set the Express Checkout token
If the API call succeded, then redirect the buyer to PayPal
to begin to authorize payment. If an error occured, show the
resulting errors
*/
$resArray = paypal_hash_call("SetExpressCheckout", $nvpstr);
wpsc_update_customer_meta('paypal_express_reshash', $resArray);
$ack = strtoupper($resArray["ACK"]);
if ($ack == "SUCCESS") {
// Redirect to paypal.com here
$token = urldecode($resArray["TOKEN"]);
$payPalURL = $PAYPAL_URL . $token;
wp_redirect($payPalURL);
} else {
// Redirecting to APIError.php to display errors.
$location = get_option('transact_url') . "&act=error";
wp_redirect($location);
}
exit;
} else {
/* At this point, the buyer has completed in authorizing payment
at PayPal. The script will now call PayPal with the details
of the authorization, incuding any shipping information of the
buyer. Remember, the authorization is not a completed transaction
at this state - the buyer still needs an additional step to finalize
the transaction
*/
$token = urlencode($_REQUEST['token']);
/* Build a second API request to PayPal, using the token as the
ID to get the details on the payment authorization
*/
$nvpstr = "&TOKEN=" . $token;
/* Make the API call and store the results in an array. If the
call was a success, show the authorization details, and provide
an action to complete the payment. If failed, show the error
*/
$resArray = paypal_hash_call("GetExpressCheckoutDetails", $nvpstr);
wpsc_update_customer_meta('paypal_express_reshash', $resArray);
$ack = strtoupper($resArray["ACK"]);
if ($ack == "SUCCESS") {
/********************************************************
GetExpressCheckoutDetails.php
This functionality is called after the buyer returns from
PayPal and has authorized the payment.
Displays the payer details returned by the
GetExpressCheckoutDetails response and calls
DoExpressCheckoutPayment.php to complete the payment
authorization.
Called by ReviewOrder.php.
Calls DoExpressCheckoutPayment.php and APIError.php.
********************************************************/
/* Collect the necessary information to complete the
authorization for the PayPal payment
*/
/* Display the API response back to the browser .
If the response from PayPal was a success, display the response parameters
*/
if (isset($_REQUEST['token']) && !isset($_REQUEST['PayerID'])) {
wpsc_update_customer_meta('paypal_express_message', _x('<h4>TRANSACTION CANCELED</h4>', 'paypal express cancel header', 'wpsc'));
} else {
wpsc_update_customer_meta('paypal_express_token', $_REQUEST['token']);
wpsc_update_customer_meta('paypal_express_payer_id', $_REQUEST['PayerID']);
$resArray = wpsc_get_customer_meta('paypal_express_reshash');
if (get_option('permalink_structure') != '') {
$separator = "?";
} else {
$separator = "&";
}
if (!isset($resArray['SHIPTOSTREET2'])) {
$resArray['SHIPTOSTREET2'] = '';
}
$output = "\n\t\t\t\t\t <table width='400' class='paypal_express_form'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'><b>" . __('Order Total:', 'wpsc') . "</b></td>\n\t\t\t\t\t\t\t<td align='left'>" . wpsc_currency_display(wpsc_get_customer_meta('paypal_express_original_amount')) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' colspan='2'><b>" . __('Shipping Address:', 'wpsc') . " </b></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Street 1:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOSTREET'] . "</td>\n\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Street 2:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOSTREET2'] . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('City:', 'wpsc') . "</td>\n\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOCITY'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('State:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOSTATE'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Postal code:', 'wpsc') . "</td>\n\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOZIP'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Country:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOCOUNTRYNAME'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2'>";
$output .= "<form action=" . get_option('transact_url') . " method='post'>\n";
$output .= "\t<input type='hidden' name='totalAmount' value='" . wpsc_cart_total(false) . "' />\n";
$output .= "\t<input type='hidden' name='shippingStreet' value='" . $resArray['SHIPTOSTREET'] . "' />\n";
$output .= "\t<input type='hidden' name='shippingStreet2' value='" . $resArray['SHIPTOSTREET2'] . "' />\n";
$output .= "\t<input type='hidden' name='shippingCity' value='" . $resArray['SHIPTOCITY'] . "' />\n";
$output .= "\t<input type='hidden' name='shippingState' value='" . $resArray['SHIPTOSTATE'] . "' />\n";
$output .= "\t<input type='hidden' name='postalCode' value='" . $resArray['SHIPTOZIP'] . "' />\n";
$output .= "\t<input type='hidden' name='country' value='" . $resArray['SHIPTOCOUNTRYNAME'] . "' />\n";
$output .= "\t<input type='hidden' name='token' value='" . wpsc_get_customer_meta('paypal_express_token') . "' />\n";
$output .= "\t<input type='hidden' name='PayerID' value='" . wpsc_get_customer_meta('paypal_express_payer_id') . "' />\n";
$output .= "\t<input type='hidden' name='act' value='do' />\n";
$output .= "\t<p> <input name='usePayPal' type='submit' value='" . __('Confirm Payment', 'wpsc') . "' /></p>\n";
$output .= "</form>";
$output .= " </td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</center>\n\t\t\t\t\t";
wpsc_update_customer_meta('paypal_express_message', $output);
}
}
}
}
}
}
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:101,代码来源:paypal-express.merchant.php
示例6: 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 = $_SESSION['wpsc_selected_country'];
if (isset($_POST['billing_country'])) {
$wpsc_selected_country = $wpdb->escape($_POST['billing_country']);
$_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
}
if (isset($_POST['billing_region'])) {
$wpsc_selected_region = absint($_POST['billing_region']);
$_SESSION['wpsc_selected_region'] = $wpsc_selected_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` = '" . $_SESSION['wpsc_selected_region'] . "' LIMIT 1");
if ($_SESSION['wpsc_selected_country'] != $check_country_code) {
$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();
$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']) {
//.........这里部分代码省略.........
开发者ID:hornet9,项目名称:Morato,代码行数:101,代码来源:ajax.functions.php
示例7: wpsc_is_free_cart
/**
* Checks if the current cart is a "Free Cart", which means one of the following:
*
* - Either the all of the cart items are priced at 0.
* - Or a coupon has been applied that results in a free cart.
*
* This is a helpful function for doing things like allowing free carts to be purchased, bypassing payment gateways.
*
* @since 3.9.0
* @return bool Whether or not the current cart's total cost is free or not.
*/
function wpsc_is_free_cart()
{
return apply_filters('wpsc_is_free_cart', wpsc_cart_item_count() && !floatval(wpsc_cart_total(false)));
}
开发者ID:parkesma,项目名称:WP-e-Commerce,代码行数:15,代码来源:cart-template-api.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: validate_forms
/**
* validate_forms method, validates the input from the checkout page
* @access public
*/
function validate_forms()
{
global $wpdb, $current_user, $user_ID;
$any_bad_inputs = false;
// Credit Card Number Validation for Paypal Pro and maybe others soon
if (wpsc_cart_total(false) != 0) {
if (isset($_POST['card_number'])) {
if ($_POST['card_number'] != '') {
/*
$ccregex='/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/';
if(!preg_match($ccregex, $_POST['card_number'])){
$any_bad_inputs = true;
$bad_input = true;
$_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid', 'wpsc') . " " . strtolower('card number') . ".";
$_SESSION['wpsc_checkout_saved_values']['card_number'] = '';
}else{
$_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
}
*/
} else {
$any_bad_inputs = true;
$bad_input = true;
$_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid', 'wpsc') . " " . strtolower('card number') . ".";
$_SESSION['wpsc_checkout_saved_values']['card_number'] = '';
}
} else {
$_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
}
if (isset($_POST['card_number1']) && isset($_POST['card_number2']) && isset($_POST['card_number3']) && isset($_POST['card_number4'])) {
if ($_POST['card_number1'] != '' && $_POST['card_number2'] != '' && $_POST['card_number3'] != '' && $_POST['card_number4'] != '' && is_numeric($_POST['card_number1']) && is_numeric($_POST['card_number2']) && is_numeric($_POST['card_number3']) && is_numeric($_POST['card_number4'])) {
$_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
} else {
$any_bad_inputs = true;
$bad_input = true;
$_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid', 'wpsc') . " " . strtolower('card number') . ".";
$_SESSION['wpsc_checkout_saved_values']['card_number'] = '';
}
}
if (isset($_POST['expiry'])) {
if ($_POST['expiry']['month'] != '' && $_POST['expiry']['month'] != '' && is_numeric($_POST['expiry']['month']) && is_numeric($_POST['expiry']['year'])) {
$_SESSION['wpsc_gateway_error_messages']['expdate'] = '';
} else {
$any_bad_inputs = true;
$bad_input = true;
$_SESSION['wpsc_gateway_error_messages']['expdate'] = __('Please enter a valid', 'wpsc') . " " . strtolower('Expiry Date') . ".";
$_SESSION['wpsc_checkout_saved_values']['expdate'] = '';
}
}
if (isset($_POST['card_code'])) {
if ($_POST['card_code'] == '' || !is_numeric($_POST['card_code'])) {
$any_bad_inputs = true;
$bad_input = true;
$_SESSION['wpsc_gateway_error_messages']['card_code'] = __('Please enter a valid', 'wpsc') . " " . strtolower('CVV') . ".";
$_SESSION['wpsc_checkout_saved_values']['card_code'] = '';
} else {
$_SESSION['wpsc_gateway_error_messages']['card_code'] = '';
}
}
if (isset($_POST['cctype'])) {
if ($_POST['cctype'] == '') {
$any_bad_inputs = true;
$bad_input = true;
$_SESSION['wpsc_gateway_error_messages']['cctype'] = __('Please enter a valid', 'wpsc') . " " . strtolower('CVV') . ".";
$_SESSION['wpsc_checkout_saved_values']['cctype'] = '';
} else {
$_SESSION['wpsc_gateway_error_messages']['cctype'] = '';
}
}
}
//closes main bracket
if (isset($_POST['log']) || isset($_POST['pwd']) || isset($_POST['user_email'])) {
$results = wpsc_add_new_user($_POST['log'], $_POST['pwd'], $_POST['user_email']);
$_SESSION['wpsc_checkout_user_error_messages'] = array();
if (is_callable(array($results, "get_error_code")) && $results->get_error_code()) {
foreach ($results->get_error_codes() as $code) {
foreach ($results->get_error_messages($code) as $error) {
$_SESSION['wpsc_checkout_user_error_messages'][] = $error;
}
$any_bad_inputs = true;
}
}
//exit('<pre>'.print_r($results, true).'</pre>');
if ($results->ID > 0) {
$our_user_id = $results->ID;
} else {
$any_bad_inputs = true;
}
}
if ($our_user_id < 1) {
$our_user_id = $user_ID;
}
// check we have a user id
if ($our_user_id > 0) {
$user_ID = $our_user_id;
}
//.........这里部分代码省略.........
开发者ID:kasima,项目名称:wp-e-commerce-ezp,代码行数:101,代码来源:checkout.class.php
示例10: compare_logic
//.........这里部分代码省略.........
}
break;
case 'less':
//Checks if the quantity of a product is less than the condition value
if ($product_obj->quantity < $c['value']) {
return true;
}
break;
case 'contains':
//Checks if the product name contains the condition value
preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
if (!empty($match)) {
return true;
}
break;
case 'not_contain':
//Checks if the product name contains the condition value
preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
if (empty($match)) {
return true;
}
break;
case 'begins':
//Checks if the product name begins with condition value
preg_match("/^" . $c['value'] . "/", $product_obj->quantity, $match);
if (!empty($match)) {
return true;
}
break;
case 'ends':
//Checks if the product name ends with condition value
preg_match("/" . $c['value'] . "\$/", $product_obj->quantity, $match);
if (!empty($match)) {
return true;
}
break;
default:
return false;
}
} else {
if ($c['property'] == 'total_quantity') {
// exit('<pre>'.print_r($product_obj, true).'</pre>');
$total_quantity = $product_obj->quantity;
switch ($c['logic']) {
case 'equal':
//Checks if the quantity of products in the cart equals condition value
if ($total_quantity == $c['value']) {
return true;
}
break;
case 'greater':
//Checks if the quantity in the cart is greater than the condition value
if ($total_quantity > $c['value']) {
return true;
}
break;
case 'less':
//Checks if the quantity in the cart is less than the condition value
if ($total_quantity < $c['value']) {
return true;
}
break;
default:
return false;
}
} else {
if ($c['property'] == 'subtotal_amount') {
$subtotal = wpsc_cart_total(false);
//exit('<pre>'.print_r($subtotal,true).'</pre>');
switch ($c['logic']) {
case 'equal':
//Checks if the subtotal of products in the cart equals condition value
if ($subtotal == $c['value']) {
return true;
}
break;
case 'greater':
//Checks if the subtotal of the cart is greater than the condition value
// exit('triggered here'.$subtotal.'>'.$c['value']);
if ($subtotal > $c['value']) {
return true;
}
break;
case 'less':
//Checks if the subtotal of the cart is less than the condition value
if ($subtotal < $c['value']) {
//exit('<pre>'.print_r($product_obj->cart->subtotal, true).'</pre>cValue'.$c['value']);
return true;
} else {
return false;
}
break;
default:
return false;
}
}
}
}
}
}
开发者ID:papayalabs,项目名称:htdocs,代码行数:101,代码来源:coupons.class.php
示例11: gateway_paypal_payflow
function gateway_paypal_payflow($seperator, $sessionid)
{
global $wpdb, $wpsc_cart;
$purchase_log_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1";
$purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
$fraud = 'NO';
$env = get_option('paypal_payflow_test') ? 'Test' : 'Live';
$user = get_option('paypal_payflow_user');
$password = get_option('paypal_payflow_pass');
$partner = get_option('paypal_payflow_partner');
$vendor = get_option('paypal_payflow_vendor');
$currency = get_option('paypal_payflow_curcode');
if ($env == 'Live') {
$submiturl = 'https://payflowpro.paypal.com';
$PayPalURL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
} else {
$submiturl = 'https://pilot-payflowpro.paypal.com';
$PayPalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
}
$cart_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='" . $purchase_log[0]['id'] . "'";
$cart = $wpdb->get_results($cart_sql, ARRAY_A);
$member_subtype = get_product_meta($cart[0]['prodid'], 'is_permenant', true);
$member_shiptype = get_product_meta($cart[0]['prodid'], 'membership_length', true);
$member_shiptype = $member_shiptype[0];
$status = get_product_meta($cart[0]['prodid'], 'is_membership', true);
$is_member = $status;
$is_perm = $member_subtype;
$length = $member_shiptype['length'];
$custom = $purchase_log[0]['id'];
if ($_POST['collected_data'][get_option('paypal_form_first_name')] != '') {
$data['first_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_first_name')]);
}
if ($_POST['collected_data'][get_option('paypal_form_last_name')] != '') {
$data['last_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_last_name')]);
}
if ($_POST['collected_data'][get_option('paypal_form_address')] != '') {
$address_rows = explode("\n\r", $_POST['collected_data'][get_option('paypal_form_address')]);
$data['address1'] = urlencode(str_replace(array("\n", "\r"), '', $address_rows[0]));
unset($address_rows[0]);
if ($address_rows != null) {
$data['address2'] = implode(", ", $address_rows);
} else {
$data['address2'] = '';
}
}
if ($_POST['collected_data'][get_option('paypal_form_city')] != '') {
$data['city'] = urlencode($_POST['collected_data'][get_option('paypal_form_city')]);
}
if ($_POST['collected_data'][get_option('paypal_form_state')] != '') {
$data['state'] = $wpdb->get_var("SELECT code FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE id='" . wpsc_get_customer_meta('billing_region') . "'");
}
$customer_billing_country = wpsc_get_customer_meta('billing_country');
if (preg_match("/^[a-zA-Z]{2}\$/", $customer_billing_country)) {
$data['country'] = $customer_billing_country;
}
if (is_numeric($_POST['collected_data'][get_option('paypal_form_post_code')])) {
$data['zip'] = urlencode($_POST['collected_data'][get_option('paypal_form_post_code')]);
}
$email_data = $wpdb->get_results("SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1'", ARRAY_A);
foreach ((array) $email_data as $email) {
$data['email'] = $_POST['collected_data'][$email['id']];
}
if ($_POST['collected_data'][get_option('email_form_field')] != null && $data['email'] == null) {
$data['email'] = $_POST['collected_data'][get_option('email_form_field')];
}
$card_num = $_POST['card_number'];
$cvv2 = $_POST['card_cvv'];
$expiry = $_POST['expiry']['month'] . $_POST['expiry']['year'];
$unique_id = generateGUID();
$fname = $data['first_name'];
$lname = $data['last_name'];
$addr1 = $data['address1'] . $data['address2'];
$addr2 = $data['city'];
$addr3 = $data['state'];
$addr4 = $data['zip'];
$country = $data['country'];
$email = $data['email'];
$amount = wpsc_cart_total(false);
$amount = number_format($amount, 2, '.', '');
if ($is_member[0]) {
switch ($member_shiptype['unit']) {
case 'w':
$member_ship_unit = 'WEEK';
break;
case 'm':
$member_ship_unit = 'MONT';
break;
case 'y':
$member_ship_unit = 'YEAR';
break;
}
$paypal_query_array = array('USER' => $user, 'PROFILENAME' => $fname . $lname . $purchase_log[0]['id'], 'VENDOR' => $vendor, 'PARTNER' => $partner, 'PWD' => $password, 'TENDER' => 'C', 'TRXTYPE' => 'R', 'ACTION' => 'A', 'START' => date('m') . (date('d') + 1) . date('Y'), 'ACCT' => $card_num, 'CVV2' => $cvv2, 'EXPDATE' => $expiry, 'ACCTTYPE' => $card, 'AMT' => $amount, 'CURRENCY' => $currency, 'FIRSTNAME' => $fname, 'LASTNAME' => $lname, 'STREET' => $addr1, 'CITY' => $addr2, 'STATE' => $addr3, 'ZIP' => $addr4, 'COUNTRY' => $country, '
|
请发表评论