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


PHP wpsc_update_customer_meta函数代码示例

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


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

示例1: wpsc_save_customer_details

function wpsc_save_customer_details($customer_details)
{
    $customer_details = apply_filters('wpsc_update_customer_checkout_details', $customer_details);
    // legacy filter
    if (is_user_logged_in()) {
        $customer_details = apply_filters('wpsc_checkout_user_profile_update', $customer_details, get_current_user_id());
    }
    wpsc_update_customer_meta('checkout_details', $customer_details);
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:9,代码来源:customer.php

示例2: gateway_google

function gateway_google($fromcheckout = false)
{
    global $wpdb, $wpsc_cart, $wpsc_checkout, $current_user, $purchlogs;
    if (!isset($wpsc_checkout)) {
        $wpsc_checkout = new wpsc_checkout();
    }
    $sessionid = (string) wpsc_get_customer_meta('google_checkout_session_id');
    if (empty($sessionid)) {
        $sessionid = mt_rand(100, 999) . time();
        wpsc_update_customer_meta('google_checkout_session_id', $sessionid);
    }
    $delivery_region = wpsc_get_customer_meta('shipping_region');
    $billing_region = wpsc_get_customer_meta('billing_region');
    if (!$billing_region && !$billing_region) {
        $base_region = get_option('base_region');
        wpsc_update_customer_meta('shipping_region', $base_region);
        wpsc_update_customer_meta('billing_region', $base_region);
    }
    $wpsc_cart->get_shipping_option();
    $wpsc_cart->get_shipping_quotes();
    $wpsc_cart->get_shipping_method();
    $wpsc_cart->google_shipping_quotes();
    $subtotal = $wpsc_cart->calculate_subtotal();
    $base_shipping = $wpsc_cart->calculate_total_shipping();
    $tax = $wpsc_cart->calculate_total_tax();
    $total = $wpsc_cart->calculate_total_price();
    if ($total > 0) {
        $update = $wpdb->update(WPSC_TABLE_PURCHASE_LOGS, array('totalprice' => $total, 'statusno' => 0, 'user_ID' => $user_ID, 'date' => time(), 'gateway' => 'google', 'billing_country' => $wpsc_cart->delivery_country, 'shipping_country' => $wpsc_cart->selected_country, 'base_shipping' => $base_shipping, 'shipping_method' => $wpsc_cart->selected_shipping_method, 'shipping_option' => $wpsc_cart->selected_shipping_option, 'plugin_version' => WPSC_VERSION, 'discount_value' => $wpsc_cart->coupons_amount, 'discount_data' => $wpsc_cart->coupons_name), array('sessionid' => $sessionid), array('%f', '%d', '%d', '%s', '%s', '%s', '%s', '%f', '%s', '%s', '%s', '%f', '%s'), '%s');
        $sql = $wpdb->prepare("SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE sessionid = %s", $sessionid);
        $purchase_log_id = $wpdb->get_var($sql);
        if (!empty($purchase_log_id)) {
            $sql = $wpdb->prepare("DELETE FROM  `" . WPSC_TABLE_CART_CONTENTS . "` WHERE purchaseid = %d", $purchase_log_id);
            $wpdb->query($sql);
        }
        if (!$update) {
            $wpdb->insert(WPSC_TABLE_PURCHASE_LOGS, array('totalprice' => $total, 'statusno' => 0, 'sessionind' => $sessionid, 'user_ID' => $user_ID, 'date' => time(), 'gateway' => 'google', 'billing_country' => $wpsc_cart->delivery_country, 'shipping_country' => $wpsc_cart->selected_country, 'base_shipping' => $base_shipping, 'shipping_method' => $wpsc_cart->selected_shipping_method, 'shipping_option' => $wpsc_cart->selected_shipping_option, 'plugin_version' => WPSC_VERSION, 'discount_value' => $wpsc_cart->coupons_amount, 'discount_data' => $wpsc_cart->coupons_name), array('%f', '%d', '%s', '%d', '%s', '%s', '%s', '%f', '%s', '%s', '%s', '%s', '%f', '%s'), '%s');
            $purchase_log_id = $wpdb->insert_id;
        }
        $wpsc_cart->save_to_db($purchase_log_id);
        if (get_option('permalink_structure') != '') {
            $separator = "?";
        } else {
            $separator = "&";
        }
        Usecase($separator, $sessionid, $fromcheckout);
    }
}
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:47,代码来源:GoogleCheckout-XML.php

示例3: _wpsc_copy_billing_details

function _wpsc_copy_billing_details()
{
    $form = WPSC_Checkout_Form::get();
    $fields = $form->get_fields();
    $fields_to_copy = array('firstname', 'lastname', 'address', 'city', 'state', 'country', 'postcode');
    $field_ids = array('shipping' => array(), 'billing' => array());
    foreach ($fields as $field) {
        if (!empty($field->unique_name) && preg_match('/^(billing|shipping)(.+)/', $field->unique_name, $matches) && in_array($matches[2], $fields_to_copy)) {
            $field_ids[$matches[1]][$matches[2]] = $field->id;
        }
    }
    $post_data =& $_POST['wpsc_checkout_details'];
    foreach ($field_ids['shipping'] as $name => $id) {
        $billing_field_id = $field_ids['billing'][$name];
        $post_data[$id] = $post_data[$billing_field_id];
    }
    wpsc_update_customer_meta('wpsc_copy_billing_details', '1');
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:18,代码来源:customer.php

示例4: wpec_auth_delete

 function wpec_auth_delete($type, $id)
 {
     $myGateway = new wpec_auth_net();
     if ($type != 'shippingadress') {
         $result = $myGateway->deletePay($id);
         if ($result === false) {
             wpsc_update_customer_meta('auth_net_message', $result);
         } else {
             wpsc_update_customer_meta('auth_net_message', __('Saved Payment Details Have Been Deleted.', 'wpsc_gold_cart'));
         }
     } else {
         $result = $myGateway->deleteShip($id);
         if ($result === false) {
             wpsc_update_customer_meta('auth_net_message', $result);
         } else {
             wpsc_update_customer_meta('auth_net_message', __('Saved Shipping Details Have Been Deleted.', 'wpsc_gold_cart'));
         }
     }
 }
开发者ID:benhuson,项目名称:Gold-Cart,代码行数:19,代码来源:user_profile.php

示例5: _wpsc_action_setup_customer

/**
 * Setup current user object and customer ID as well as cart.
 *
 * @uses  do_action() Calls 'wpsc_setup_customer' after customer data is ready
 * @access private
 * @since  3.8.13
 * @return int visitor id
 *
 */
function _wpsc_action_setup_customer()
{
    /////////////////////////////////////////////////////////////////////////
    // Setting up the customer happens after WPEC is initialized AND after
    // WordPress has loaded.  The reason for this is that the conditional
    // query tags are checked to see if the request is a 404 or a feed or
    // some other request that should not create a visitor profile.  The
    // conditional query tags are not available until after the
    // posts_selection hook is processed.  The 'wp' action is fired after
    // the 'posts_selection' hook.
    /////////////////////////////////////////////////////////////////////////
    if (!did_action('init')) {
        _wpsc_doing_it_wrong(__FUNCTION__, __('Customer cannot be reliably setup until at least the "init" hook as been fired during AJAX processing.', 'wpsc'), '3.8.14');
    }
    // if the customer cookie is invalid, unset it
    $visitor_id_from_cookie = _wpsc_validate_customer_cookie();
    if ($visitor_id_from_cookie && is_user_logged_in()) {
        $id_from_wp_user = get_user_meta(get_current_user_id(), _wpsc_get_visitor_meta_key('visitor_id'), true);
        if (empty($id_from_wp_user)) {
            _wpsc_update_wp_user_visitor_id(get_current_user_id(), $visitor_id_from_cookie);
        } elseif ($visitor_id_from_cookie != $id_from_wp_user) {
            // save the old visitor id so the merge cart function can do its work
            wpsc_update_customer_meta('merge_cart_vistor_id', $visitor_id_from_cookie);
            // make the current customer cookie match the cookie that is in the WordPress user meta
            _wpsc_create_customer_id_cookie($id_from_wp_user);
            // merging cart requires the taxonomies to have been initialized
            if (did_action('wpsc_register_taxonomies_after')) {
                _wpsc_merge_cart();
            } else {
                add_action('wpsc_register_taxonomies_after', '_wpsc_merge_cart', 1);
            }
        }
    }
    // initialize customer ID if it's not already there
    $visitor_id = wpsc_get_current_customer_id();
    // if there wasn't a visitor id in the cookies we set it now
    if ($visitor_id && empty($visitor_id_from_cookie) && is_user_logged_in()) {
        _wpsc_create_customer_id_cookie($visitor_id);
    }
    // setup the cart and restore its items
    wpsc_core_setup_cart();
    do_action('wpsc_setup_customer', $visitor_id);
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:52,代码来源:customer-private.php

示例6: update_location

 /**
  * update_location method, updates the location
  * @access public
  */
 function update_location()
 {
     $delivery_country = wpsc_get_customer_meta('shipping_country');
     $billing_country = wpsc_get_customer_meta('billing_country');
     $delivery_region = wpsc_get_customer_meta('shipping_region');
     $billing_region = wpsc_get_customer_meta('billing_region');
     if (!$billing_country && !$delivery_country) {
         $billing_country = $delivery_country = get_option('base_country');
     } elseif (!$billing_country) {
         $billing_country = $delivery_country;
     } elseif (!$delivery_country) {
         $delivery_country = $billing_country;
     }
     if (!$billing_region && !$delivery_region) {
         $billing_region = $delivery_region = get_option('base_region');
     }
     wpsc_update_customer_meta('shipping_country', $delivery_country);
     wpsc_update_customer_meta('billing_country', $billing_country);
     wpsc_update_customer_meta('delivery_region', $delivery_region);
     wpsc_update_customer_meta('billing_region', $billing_region);
     $this->delivery_country = $delivery_country;
     $this->selected_country = $billing_country;
     $this->delivery_region = $delivery_region;
     $this->selected_region = $billing_region;
     //adding refresh item
     $this->wpsc_refresh_cart_items();
 }
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:31,代码来源:cart.class.php

示例7: wpsc_customer_updated_data_ajax

/**
 * Update customer information using information supplied by shopper on WPeC pages
 *
 * @since 3.8.14
 *
 * @global  $_REQUEST['meta_data']  array of key value pairs that the user has changed, key is meta item name, value is new value
 *
 * @return JSON encoded response array with results
 *
 * 			$RESPONSE['request']		: 	array containing the original AJAX $_REQUEST that was sent to
 * 											the server, use to match up asynchronous AJAX transactions, or
 * 											to see original rquiest paramters
 *
 * 			$RESPONSE['customer_meta']	: 	array of key value pairs containing updated meta values. The
 * 											specific value changed is not included. If there isn't any updated
 * 											customer meta, other than the original meta changed, this array element
 * 											may not be present, or may be present and empty
 *
 * 			$response['checkout_info']  :	array of updated checkout information, array key is the HTML element ID
 * 											where the information is presented on the checkout form. If there isn't
 * 											any updated	checkout information this array element	may not be present,
 * 											or may be present and empty
 *
 *
 */
function wpsc_customer_updated_data_ajax()
{
    $success = true;
    // we will echo back the request in the (likely async) response so that the client knows
    // which transaction the response matches
    $response = array('request' => $_REQUEST);
    // update can be a single key/value pair or an array of key value pairs
    if (!empty($_REQUEST['meta_data'])) {
        $customer_meta = isset($_REQUEST['meta_data']) ? $_REQUEST['meta_data'] : array();
    } elseif (!empty($_REQUEST['meta_key']) && isset($_REQUEST['meta_value'])) {
        $customer_meta = array($_REQUEST['meta_key'] => $_REQUEST['meta_value']);
    } else {
        _wpsc_doing_it_wrong(__FUNCTION__, __('missing meta key or meta array', 'wpsc'), '3.8.14');
        $customer_meta = array();
    }
    // We will want to know which interface elements have changed as a result of this meta update,
    // capture the current state of the elements
    $checkout_info_before_updates = _wpsc_get_checkout_info();
    // We will want to know which, if any, checkout meta changes as a result of hooks and filters
    // that may fire as we update each meta item
    $all_checkout_meta_before_updates = _wpsc_get_checkout_meta();
    if (!empty($customer_meta)) {
        foreach ($customer_meta as $meta_key => $meta_value) {
            // this will echo back any fields to the requester. It's a
            // means for the requester to maintain some state during
            // asynchronous requests
            if (!empty($meta_key)) {
                $updated = wpsc_update_customer_meta($meta_key, $meta_value);
                $success = $success & $updated;
            }
        }
        // loop through a second time so that all of the meta has been set, tht way if there are
        // dependencies in response calculation
        foreach ($customer_meta as $meta_key => $meta_value) {
            $response = apply_filters('wpsc_customer_meta_response_' . $meta_key, $response, $meta_key, $meta_value);
        }
        if ($success) {
            $response['type'] = 'success';
            $response['error'] = '';
        } else {
            $response['type'] = 'error';
            $response['error'] = __('meta values may not have been updated', 'wpsc');
        }
    } else {
        $response['type'] = 'error';
        $response['error'] = __('invalid parameters, meta array or meta key value pair required', 'wpsc');
    }
    // Let's see what the current state of the customer meta set is after we applied the requested updates
    $all_checkout_meta_after_updates = _wpsc_get_checkout_meta();
    foreach ($all_checkout_meta_after_updates as $current_meta_key => $current_meta_value) {
        // if the meta key and value are the same as what was sent in the request we don't need to
        // send them back because the client already knows about this.
        //
        // But we have to check just in case a data rule or a plugin that used our hooks made some adjustments
        if (isset($all_checkout_meta_before_updates[$current_meta_key]) && $all_checkout_meta_before_updates[$current_meta_key] == $current_meta_value) {
            // new value s the same as the old value, why send it?
            unset($all_checkout_meta_after_updates[$current_meta_key]);
            unset($all_checkout_meta_before_updates[$current_meta_key]);
            continue;
        }
        // if the meta value we are considering sending back is one of the values the client gave, we don't send it
        // because the client already knows the meta value and it is probably already visible in the user interface
        if (isset($customer_meta[$current_meta_key]) && $customer_meta[$current_meta_key] == $current_meta_value) {
            // new value s the same as the old value, why send it?
            unset($all_checkout_meta_after_updates[$current_meta_key]);
            continue;
        }
    }
    // Any checkout meta that has changed as a result of the requeeted updates remains
    // in our array, add it to the response
    $response['customer_meta'] = $all_checkout_meta_after_updates;
    // Get the changed checkout information and if something has changed add it to the repsonse
    $new_checkout_info = _wpsc_remove_unchanged_checkout_info($checkout_info_before_updates, _wpsc_get_checkout_info());
    if (!empty($new_checkout_info)) {
        $response['checkout_info'] = $new_checkout_info;
//.........这里部分代码省略.........
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:101,代码来源:wpsc-checkout-ajax.php

示例8: save_customer_settings

 private function save_customer_settings()
 {
     $form = WPSC_Checkout_Form::get();
     $fields = $form->get_fields();
     $customer_details = wpsc_get_customer_meta('checkout_details');
     if (!is_array($customer_details)) {
         $customer_details = array();
     }
     foreach ($fields as $field) {
         if (!array_key_exists($field->id, $_POST['wpsc_checkout_details'])) {
             continue;
         }
         $value = $_POST['wpsc_checkout_details'][$field->id];
         $customer_details[$field->id] = $value;
         switch ($field->unique_name) {
             case 'billingstate':
                 wpsc_update_customer_meta('billing_region', $value);
                 break;
             case 'shippingstate':
                 wpsc_update_customer_meta('shipping_region', $value);
                 break;
             case 'billingcountry':
                 wpsc_update_customer_meta('billing_country', $value);
                 break;
             case 'shippingcountry':
                 wpsc_update_customer_meta('shipping_country', $value);
                 break;
             case 'shippingpostcode':
                 wpsc_update_customer_meta('shipping_zip', $value);
                 break;
         }
     }
     _wpsc_update_location();
     wpsc_save_customer_details($customer_details);
 }
开发者ID:parkesma,项目名称:WP-e-Commerce,代码行数:35,代码来源:customer-account.php

示例9: validate_form_data

function validate_form_data()
{
    global $wpdb, $user_ID, $wpsc_purchlog_statuses;
    $any_bad_inputs = false;
    $changes_saved = false;
    $bad_input_message = '';
    $_SESSION['collected_data'] = null;
    if (!empty($_POST['collected_data'])) {
        if (!wp_verify_nonce($_POST['_wpsc_user_profile'], 'wpsc_user_profile')) {
            die(__('It would appear either you are trying to hack into this account, or your session has expired.  Hoping for the latter.', 'wpsc'));
        }
        foreach ((array) $_POST['collected_data'] as $value_id => $value) {
            $form_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = %d LIMIT 1", $value_id);
            $form_data = $wpdb->get_row($form_sql, ARRAY_A);
            $bad_input = false;
            if ($form_data['mandatory'] == 1) {
                switch ($form_data['type']) {
                    case "email":
                        if (!preg_match("/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-.]+\\.[a-zA-Z]{2,5}\$/", $value)) {
                            $any_bad_inputs = true;
                            $bad_input = true;
                        }
                        break;
                    case "delivery_country":
                        if ($value != null) {
                            wpsc_update_customer_meta('shipping_country', $value);
                        }
                        break;
                    default:
                        if (empty($value)) {
                            $bad_input = true;
                        }
                        break;
                }
                if ($bad_input === true) {
                    switch ($form_data['name']) {
                        case __('First Name', 'wpsc'):
                            $bad_input_message .= __('Please enter a valid name', 'wpsc') . "";
                            break;
                        case __('Last Name', 'wpsc'):
                            $bad_input_message .= __('Please enter a valid surname', 'wpsc') . "";
                            break;
                        case __('Email', 'wpsc'):
                            $bad_input_message .= __('Please enter a valid email address', 'wpsc') . "";
                            break;
                        case __('Address 1', 'wpsc'):
                        case __('Address 2', 'wpsc'):
                            $bad_input_message .= __('Please enter a valid address', 'wpsc') . "";
                            break;
                        case __('City', 'wpsc'):
                            $bad_input_message .= __('Please enter your town or city.', 'wpsc') . "";
                            break;
                        case __('Phone', 'wpsc'):
                            $bad_input_message .= __('Please enter a valid phone number', 'wpsc') . "";
                            break;
                        case __('Country', 'wpsc'):
                            $bad_input_message .= __('Please select your country from the list.', 'wpsc') . "";
                            break;
                        default:
                            $bad_input_message .= sprintf(__('Please enter a valid <span class="wpsc_error_msg_field_name">%s</span>.', 'wpsc'), esc_html($form_data['name']));
                            break;
                    }
                    $bad_input_message .= "<br />";
                } else {
                    $meta_data[$value_id] = $value;
                }
            } else {
                $meta_data[$value_id] = $value;
            }
        }
        $meta_data = apply_filters('wpsc_user_log_update', $meta_data, $user_ID);
        wpsc_update_customer_meta('checkout_details', $meta_data);
    }
    if ($changes_saved) {
        $message = __('Thanks, your changes have been saved.', 'wpsc');
    } else {
        $message = $bad_input_message;
    }
    return apply_filters('wpsc_profile_message', $message);
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:80,代码来源:wpsc-user_log_functions.php

示例10: getQuote

 function getQuote()
 {
     global $wpdb, $wpsc_cart;
     if ($this->base_country != 'AU' || strlen($this->base_zipcode) != 4 || !count($wpsc_cart->cart_items)) {
         return;
     }
     $dest = wpsc_get_customer_meta('shipping_country');
     $destzipcode = (string) wpsc_get_customer_meta('shipping_zip');
     if (isset($_POST['zipcode'])) {
         $destzipcode = sanitize_text_field($_POST['zipcode']);
         wpsc_update_customer_meta('shipping_zip', $destzipcode);
     }
     if ($dest == 'AU' && strlen($destzipcode) != 4) {
         // Invalid Australian Post Code entered, so just return an empty set of quotes instead of wasting time contactin the Aus Post API
         return array();
     }
     /*
     3 possible scenarios:
     
     1.
     Cart consists of only item(s) that have "disregard shipping" ticked.
     
     In this case, WPEC doesn't mention shipping at all during checkout, and this shipping module probably won't be executed at all.
     
     Just in case it does get queried, we should still query the Australia Post API for valid shipping estimates,
     and then override the quoted price(s) to $0.00 so the customer is able to get free shipping.
     
     
     2.
     Cart consists of only item(s) where "disregard shipping" isn't ticked (ie. all item(s) attract shipping charges).
     
     In this case, we should query the Australia Post API as per normal.
     
     
     3.
     Cart consists of one or more "disregard shipping" product(s), and one or more other products that attract shipping charges.
     
     In this case, we should query the Aus Post API, only taking into account the product(s) that attract shipping charges.
     Products with "disregard shipping" ticked shouldn't have their weight or dimensions included in the quote.
     */
     // Obtain the total combined weight for all items(s) in the cart (excluding items that have the "Disregard Shipping for this product" option ticked)
     // Weight is in grams
     $weight = wpsc_convert_weight($wpsc_cart->calculate_total_weight(true), 'pound', 'gram');
     // Calculate the total cart dimensions by adding the volume of each product then calculating the cubed root
     $volume = 0;
     // Total number of item(s) in the cart
     $numItems = count($wpsc_cart->cart_items);
     if ($numItems == 0) {
         // The customer's cart is empty. This probably shouldn't occur, but just in case!
         return array();
     }
     // Total number of item(s) that don't attract shipping charges.
     $numItemsWithDisregardShippingTicked = 0;
     foreach ($wpsc_cart->cart_items as $cart_item) {
         if (!$cart_item->uses_shipping) {
             // The "Disregard Shipping for this product" option is ticked for this item.
             // Don't include it in the shipping quote.
             $numItemsWithDisregardShippingTicked++;
             continue;
         }
         // If we are here then this item attracts shipping charges.
         $meta = get_product_meta($cart_item->product_id, 'product_metadata', true);
         $unit = $meta['dimension_unit'];
         $meta = $meta['dimensions'];
         if ($meta && is_array($meta)) {
             $productVolume = 1;
             foreach (array('width', 'height', 'length') as $dimension) {
                 // default dimension to 100mm
                 if (empty($meta[$dimension])) {
                     $meta[$dimension] = 100;
                     $unit = 'mm';
                 }
                 switch ($unit) {
                     // we need the units in mm
                     case 'cm':
                         // convert from cm to mm
                         $meta[$dimension] *= 10;
                         break;
                     case 'meter':
                         // convert from m to mm
                         $meta[$dimension] *= 1000;
                         break;
                     case 'in':
                         // convert from in to mm
                         $meta[$dimension] *= 25.4;
                         break;
                 }
                 $productVolume *= $meta[$dimension];
             }
             $volume += floatval($productVolume) * $cart_item->quantity;
         }
     }
     // If there's only one item in the cart, its dimensions will be used
     // But if there are multiple items, cubic root of total volume will be used instead
     if ($wpsc_cart->get_total_shipping_quantity() == 1) {
         $height = $meta['height'];
         $width = $meta['width'];
         $length = $meta['length'];
     } else {
         // Calculate the cubic root of the total volume, rounding up
//.........这里部分代码省略.........
开发者ID:parkesma,项目名称:WP-e-Commerce,代码行数:101,代码来源:australiapost.php

示例11: wpsc_shipping_country_list

function wpsc_shipping_country_list($shippingdetails = false)
{
    global $wpsc_shipping_modules;
    $wpsc_checkout = new wpsc_checkout();
    $wpsc_checkout->checkout_item = $shipping_country_checkout_item = $wpsc_checkout->get_checkout_item('shippingcountry');
    $output = '';
    if ($shipping_country_checkout_item && $shipping_country_checkout_item->active) {
        if (!$shippingdetails) {
            $output = "<input type='hidden' name='wpsc_ajax_action' value='update_location' />";
        }
        $acceptable_countries = wpsc_get_acceptable_countries();
        // if there is only one country to choose from we are going to set that as the shipping country,
        // later in the UI generation the same thing will happen to make the single country the current
        // selection
        $countries = WPSC_Countries::get_countries(false);
        if (count($countries) == 1) {
            reset($countries);
            $id_of_only_country_available = key($countries);
            $wpsc_country = new WPSC_Country($id_of_only_country_available);
            wpsc_update_customer_meta('shippingcountry', $wpsc_country->get_isocode());
        }
        $selected_country = wpsc_get_customer_meta('shippingcountry');
        $additional_attributes = 'data-wpsc-meta-key="shippingcountry" ';
        $output .= wpsc_get_country_dropdown(array('id' => 'current_country', 'name' => 'country', 'class' => 'current_country wpsc-visitor-meta', 'acceptable_ids' => $acceptable_countries, 'selected' => $selected_country, 'additional_attributes' => $additional_attributes, 'placeholder' => __('Please select a country', 'wp-e-commerce')));
    }
    $output .= wpsc_checkout_shipping_state_and_region();
    $zipvalue = (string) wpsc_get_customer_meta('shippingpostcode');
    $zip_code_text = __('Your Zipcode', 'wp-e-commerce');
    if ($zipvalue != '' && $zipvalue != $zip_code_text) {
        $color = '#000';
        wpsc_update_customer_meta('shipping_zip', $zipvalue);
    } else {
        $zipvalue = $zip_code_text;
        $color = '#999';
    }
    $uses_zipcode = false;
    $custom_shipping = get_option('custom_shipping_options');
    foreach ((array) $custom_shipping as $shipping) {
        if (isset($wpsc_shipping_modules[$shipping]->needs_zipcode) && $wpsc_shipping_modules[$shipping]->needs_zipcode == true) {
            $uses_zipcode = true;
        }
    }
    if ($uses_zipcode) {
        $output .= " <input data-wpsc-meta-key='shippingpostcode' class='wpsc-visitor-meta' type='text' style='color:" . $color . ";' onclick='if (this.value==\"" . esc_js($zip_code_text) . "\") {this.value=\"\";this.style.color=\"#000\";}' onblur='if (this.value==\"\") {this.style.color=\"#999\"; this.value=\"" . esc_js($zip_code_text) . "\"; }' value='" . esc_attr($zipvalue) . "' size='10' name='zipcode' id='zipcode'>";
    }
    return $output;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:47,代码来源:checkout.php

示例12: process

 /**
  * Process the SetExpressCheckout API Call
  *
  * @return void
  *
  * @since 3.9
  */
 public function process()
 {
     $total = $this->convert($this->purchase_log->get('totalprice'));
     $options = array('return_url' => $this->get_return_url(), 'message_id' => $this->purchase_log->get('id'), 'invoice' => $this->purchase_log->get('sessionid'), 'address_override' => 1);
     $options += $this->checkout_data->get_gateway_data();
     $options += $this->purchase_log->get_gateway_data(parent::get_currency_code(), $this->get_currency_code());
     if ($this->setting->get('ipn', false)) {
         $options['notify_url'] = $this->get_notify_url();
     }
     // SetExpressCheckout
     $response = $this->gateway->setup_purchase($options);
     if ($response->is_successful()) {
         $params = $response->get_params();
         if ($params['ACK'] == 'SuccessWithWarning') {
             $this->log_error($response);
             wpsc_update_customer_meta('paypal_express_checkout_errors', $response->get_errors());
         }
         // Successful redirect
         $url = $this->get_redirect_url(array('token' => $response->get('token')));
     } else {
         // SetExpressCheckout Failure
         $this->log_error($response);
         wpsc_update_customer_meta('paypal_express_checkout_errors', $response->get_errors());
         $url = add_query_arg(array('payment_gateway' => 'paypal-express-checkout', 'payment_gateway_callback' => 'display_paypal_error'), $this->get_return_url());
     }
     wp_redirect($url);
     exit;
 }
开发者ID:benhuson,项目名称:WP-e-Commerce,代码行数:35,代码来源:paypal-express-checkout.php

示例13: wpsc_update_all_customer_meta

/**
 * Overwrite customer meta with an array of meta_key => meta_value.
 *
 * Implement your own system by hooking into 'wpsc_update_all_customer_meta'.
 *
 * @access public
 * @since  3.8.9
 * @param  array      $profile Customer meta array
 * @param  int|string $id      Customer ID. Optional. Defaults to current customer.
 * @return boolean             True if meta values are updated successfully. False
 *                             if otherwise.
 */
function wpsc_update_all_customer_meta($profile, $id = false)
{
    if (!$id) {
        $id = wpsc_get_current_customer_id();
    }
    $result = apply_filters('wpsc_update_all_customer_meta', null, $profile, $id);
    if ($result) {
        return $result;
    }
    wpsc_delete_all_customer_meta($id);
    $result = true;
    foreach ($profile as $key => $value) {
        $result = $result && wpsc_update_customer_meta($key, $value, $id);
    }
    return $result;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:28,代码来源:wpsc-meta-customer.php

示例14: save_shipping_and_billing_info

 private function save_shipping_and_billing_info()
 {
     global $wpsc_cart;
     // see if an existing purchase log has been set for this user
     // otherwise create one
     $purchase_log_id = (int) wpsc_get_customer_meta('current_purchase_log_id');
     if ($purchase_log_id) {
         $purchase_log = new WPSC_Purchase_Log($purchase_log_id);
     } else {
         $purchase_log = new WPSC_Purchase_Log();
     }
     $sessionid = mt_rand(100, 999) . time();
     wpsc_update_customer_meta('checkout_session_id', $sessionid);
     $purchase_log->set(array('user_ID' => wpsc_get_current_customer_id(), 'date' => time(), 'plugin_version' => WPSC_VERSION, 'statusno' => '0', 'sessionid' => $sessionid));
     $form = WPSC_Checkout_Form::get();
     $fields = $form->get_fields();
     foreach ($fields as $field) {
         if (!array_key_exists($field->id, $_POST['wpsc_checkout_details'])) {
             continue;
         }
         $value = $_POST['wpsc_checkout_details'][$field->id];
         switch ($field->unique_name) {
             case 'billingstate':
                 wpsc_update_customer_meta('billing_region', $value);
                 $purchase_log->set('billing_region', $value);
                 break;
             case 'shippingstate':
                 wpsc_update_customer_meta('shipping_region', $value);
                 $purchase_log->set('shipping_region', $value);
                 break;
             case 'billingcountry':
                 wpsc_update_customer_meta('billing_country', $value);
                 $purchase_log->set('billing_country', $value);
                 break;
             case 'shippingcountry':
                 wpsc_update_customer_meta('shipping_country', $value);
                 $purchase_log->set('shipping_region', $value);
                 break;
             case 'shippingpostcode':
                 wpsc_update_customer_meta('shipping_zip', $value);
                 break;
         }
     }
     _wpsc_update_location();
     if (wpsc_is_tax_included()) {
         $tax = $wpsc_cart->calculate_total_tax();
         $tax_percentage = $wpsc_cart->tax_percentage;
     } else {
         $tax = 0;
         $tax_percentage = 0;
     }
     $purchase_log->set(array('wpec_taxes_total' => $tax, 'wpec_taxes_rate' => $tax_percentage));
     $purchase_log->save();
     $wpsc_cart->log_id = $purchase_log->get('id');
     wpsc_update_customer_meta('current_purchase_log_id', $purchase_log->get('id'));
     $this->save_form($purchase_log, $fields);
     $this->init_shipping_calculator();
     if (wpsc_uses_shipping() && !$this->shipping_calculator->has_quotes) {
         $this->message_collection->add(__('Sorry but we cannot ship products to your submitted address. Please either provide another shipping address or contact the store administrator about product availability to your location.', 'wpsc'), 'error');
         return;
     }
     $this->wizard->completed_step('shipping-and-billing');
     wp_redirect(wpsc_get_checkout_url($this->wizard->pending_step));
     exit;
 }
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:65,代码来源:checkout.php

示例15: set_error_message

 /**
  * set_error_message, please don't extend this without very good reason
  * saves error message, data it is stored in may need to change, hence the need to not extend this.
  */
 function set_error_message($error_message)
 {
     global $wpdb;
     $messages = wpsc_get_customer_meta('checkout_misc_error_messages');
     if (!is_array($messages)) {
         $messages = array();
     }
     $messages[] = $error_message;
     wpsc_update_customer_meta('checkout_misc_error_messages', $messages);
 }
开发者ID:benhuson,项目名称:WP-e-Commerce,代码行数:14,代码来源:merchant.class.php


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