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


PHP WPSC_Countries::country_id方法代码示例

本文整理汇总了PHP中WPSC_Countries::country_id方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSC_Countries::country_id方法的具体用法?PHP WPSC_Countries::country_id怎么用?PHP WPSC_Countries::country_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WPSC_Countries的用法示例。


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

示例1: 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


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