本文整理汇总了PHP中WPSC_Countries类的典型用法代码示例。如果您正苦于以下问题:PHP WPSC_Countries类的具体用法?PHP WPSC_Countries怎么用?PHP WPSC_Countries使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WPSC_Countries类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _wpsc_country_dropdown_options
/**
* Get the country dropdown options, presumably for the checkout or customer profile pages
*
* @param string|array $args
*
* @return string HTML representation of the dropdown
*/
function _wpsc_country_dropdown_options($args = '')
{
$defaults = array('acceptable' => null, 'acceptable_ids' => null, 'selected' => '', 'disabled' => null, 'disabled_ids' => null, 'placeholder' => __('Please select a country', 'wpsc'), 'include_invisible' => false);
$args = wp_parse_args($args, $defaults);
$output = '';
$countries = WPSC_Countries::get_countries($args['include_invisible']);
// if the user has a choice of countries the
if (count($countries) > 1 && !empty($args['placeholder'])) {
$output .= "<option value=''>" . esc_html($args['placeholder']) . "</option>\n\r";
}
foreach ($countries as $country) {
$isocode = $country->get_isocode();
$name = $country->get_name();
// if there is only one country in the list select it
if (count($countries) == 1) {
$args['selected'] = $isocode;
}
// if we're in admin area, and the legacy country code "UK" or "TP" is selected as the
// base country, we should display both this and the more proper "GB" or "TL" options
// and distinguish these choices somehow
if (is_admin() && 11 > wpsc_core_get_db_version()) {
if (in_array($isocode, array('TP', 'UK'))) {
/* translators: This string will mark the legacy isocode "UK" and "TP" in the country selection dropdown as "legacy" */
$name = sprintf(__('%s (legacy)', 'wpsc'), $name);
} elseif (in_array($isocode, array('GB', 'TL'))) {
/* translators: This string will mark the legacy isocode "GB" and "TL" in the country selection dropdown as "ISO 3166" */
$name = sprintf(__('%s (ISO 3166)', 'wpsc'), $name);
}
}
$output .= sprintf('<option value="%1$s" %2$s %3$s>%4$s</option>' . "\n\r", esc_attr($isocode), selected($args['selected'], $isocode, false), disabled(_wpsc_is_country_disabled($country, $args), true, false), esc_html($name));
}
return $output;
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:40,代码来源:country-region-tax-util.php
示例2: get_local_currency_code
function get_local_currency_code()
{
if (empty($this->local_currency_code)) {
$this->local_currency_code = WPSC_Countries::get_currency_code(get_option('currency_type'));
}
return $this->local_currency_code;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:7,代码来源:paypal-standard.merchant.php
示例3: _wpsc_countries_localizations
/**
* add countries data to the wpec javascript localizations
*
* @access private
* @since 3.8.14
*
* @param array localizations other localizations that can be added to
*
* @return array localizations array with countries information added
*/
function _wpsc_countries_localizations($localizations_array)
{
$localizations_array['no_country_selected'] = __('Please select a country', 'wpsc');
$localizations_array['no_region_selected_format'] = __('Please select a %s', 'wpsc');
$localizations_array['no_region_label'] = __('State/Province', 'wpsc');
$localizations_array['base_country'] = get_option('base_country');
$country_list = array();
foreach (WPSC_Countries::get_countries() as $country_id => $wpsc_country) {
if ($wpsc_country->is_visible()) {
$country_list[$wpsc_country->get_isocode()] = $wpsc_country->get_name();
if ($wpsc_country->has_regions()) {
$regions = $wpsc_country->get_regions();
$region_list = array();
foreach ($regions as $region_id => $wpsc_region) {
$region_list[$region_id] = $wpsc_region->get_name();
}
if (!empty($region_list)) {
$localizations_array['wpsc_country_' . $wpsc_country->get_isocode() . '_regions'] = $region_list;
}
}
$region_label = $wpsc_country->get('region_label');
if (!empty($region_label)) {
$localizations_array['wpsc_country_' . $wpsc_country->get_isocode() . '_region_label'] = $region_label;
}
}
}
if (!empty($country_list)) {
$localizations_array['wpsc_countries'] = $country_list;
}
return $localizations_array;
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:41,代码来源:checkout-localization.php
示例4: _wpsc_set_legacy_country_meta
/**
* Sets meta for countries that no longer exist in their former notation to be considered legacy.
*
* @access private
* @since 3.8.14
*/
function _wpsc_set_legacy_country_meta()
{
if ($wpsc_country = WPSC_Countries::get_country('YU')) {
$wpsc_country->set('_is_country_legacy', true);
}
if ($wpsc_country = WPSC_Countries::get_country('AN')) {
$wpsc_country->set('_is_country_legacy', true);
}
if ($wpsc_country = WPSC_Countries::get_country('TP')) {
$wpsc_country->set('_is_country_legacy', true);
}
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:18,代码来源:11.php
示例5: __construct
/**
* Create a WPSC_Currency object
*
* @access public
*
* @since 3.8.14
*
* @param string $code this currency's code, like "USD" for a U.S.A dollar, or "EUR" for a euro
* @param string $symbol the text symbol for this currency, like "$"
* @param string $symbol_html the HTML representation of the symbol, like "$"
* @param string $name the currency name, like "US Dollar" or "Euro"
*
* @return void
*/
public function __construct($code, $symbol = null, $symbol_html = null, $name = null)
{
// if all parameters are specified we are trying to make a new currency object
if (!empty($code) && ($symbol != null || $symbol_html != null || $name != null)) {
// Create a new currency object
$this->code = $code;
$this->symbol = $symbol;
$this->symbol_html = $symbol_html;
$this->name = $name;
} else {
// if only code is specified the constructor is typing to get the information about an existing currency
$wpsc_currency = WPSC_Countries::get_currency($code);
$this->code = $wpsc_currency->code;
$this->symbol = $wpsc_currency->symbol;
$this->symbol_html = $wpsc_currency->symbol_html;
$this->name = $wpsc_currency->name;
}
}
开发者ID:ashik968,项目名称:digiplot,代码行数:32,代码来源:wpsc-currency.class.php
示例6: nzshpcrt_region_list
function nzshpcrt_region_list($selected_country = null, $selected_region = null)
{
global $wpdb;
if ($selected_region == null) {
$selected_region = get_option('base_region');
}
$output = "";
$region_list = WPSC_Countries::get_regions($selected_country, true);
if ($region_list != null) {
foreach ($region_list as $region) {
if ($selected_region == $region['id']) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$output .= "<option value='" . $region['id'] . "' {$selected}>" . $region['name'] . "</option>\r\n";
}
} else {
$output .= "<option value=''>" . esc_html__('None', 'wpsc') . "</option>\r\n";
}
return $output;
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:22,代码来源:form.php
示例7: wpsc_get_region
function wpsc_get_region($region_id)
{
$country_id = WPSC_Countries::get_country_id_by_region_id($region_id);
$wpsc_region = new WPSC_Region($country_id, $region_id);
return $wpsc_region->get_name();
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:6,代码来源:misc.functions.php
示例8: save_options
/**
* Save submitted options to the database.
* @since 3.8.8
* @uses check_admin_referer() Prevents CSRF.
* @uses update_option() Saves options to the database.
* @uses wpdb::query() Queries the database.
* @uses wpdb::get_col() Queries the database.
* @access public
*/
private function save_options($selected = '')
{
global $wpdb, $wpsc_gateways;
$updated = 0;
//This is to change the Overall target market selection
check_admin_referer('update-options', 'wpsc-update-options');
//Should be refactored along with the Marketing tab
if (isset($_POST['change-settings'])) {
if (isset($_POST['wpsc_also_bought']) && $_POST['wpsc_also_bought'] == 'on') {
update_option('wpsc_also_bought', 1);
} else {
update_option('wpsc_also_bought', 0);
}
if (isset($_POST['display_find_us']) && $_POST['display_find_us'] == 'on') {
update_option('display_find_us', 1);
} else {
update_option('display_find_us', 0);
}
if (isset($_POST['wpsc_share_this']) && $_POST['wpsc_share_this'] == 'on') {
update_option('wpsc_share_this', 1);
} else {
update_option('wpsc_share_this', 0);
}
if (isset($_POST['wpsc_ga_disable_tracking']) && $_POST['wpsc_ga_disable_tracking'] == '1') {
update_option('wpsc_ga_disable_tracking', 1);
} else {
update_option('wpsc_ga_disable_tracking', 0);
}
if (isset($_POST['wpsc_ga_currently_tracking']) && $_POST['wpsc_ga_currently_tracking'] == '1') {
update_option('wpsc_ga_currently_tracking', 1);
} else {
update_option('wpsc_ga_currently_tracking', 0);
}
if (isset($_POST['wpsc_ga_advanced']) && $_POST['wpsc_ga_advanced'] == '1') {
update_option('wpsc_ga_advanced', 1);
update_option('wpsc_ga_currently_tracking', 1);
} else {
update_option('wpsc_ga_advanced', 0);
}
if (isset($_POST['wpsc_ga_tracking_id']) && !empty($_POST['wpsc_ga_tracking_id'])) {
update_option('wpsc_ga_tracking_id', esc_attr($_POST['wpsc_ga_tracking_id']));
} else {
update_option('wpsc_ga_tracking_id', '');
}
}
if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location'])) {
$selected = 'none';
}
if (!isset($_POST['countrylist2'])) {
$_POST['countrylist2'] = '';
}
if (!isset($_POST['country_id'])) {
$_POST['country_id'] = '';
}
if (!isset($_POST['country_tax'])) {
$_POST['country_tax'] = '';
}
if ($_POST['countrylist2'] != null || !empty($selected)) {
$AllSelected = false;
if ($selected == 'all') {
$wpdb->query("UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'");
$AllSelected = true;
}
if ($selected == 'none') {
$wpdb->query("UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'");
$AllSelected = true;
}
if ($AllSelected != true) {
$countrylist = $wpdb->get_col("SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ");
//find the countries not selected
$unselectedCountries = array_diff($countrylist, $_POST['countrylist2']);
foreach ($unselectedCountries as $unselected) {
$wpdb->update(WPSC_TABLE_CURRENCY_LIST, array('visible' => 0), array('id' => $unselected), '%d', '%d');
}
//find the countries that are selected
$selectedCountries = array_intersect($countrylist, $_POST['countrylist2']);
foreach ($selectedCountries as $selected) {
$wpdb->update(WPSC_TABLE_CURRENCY_LIST, array('visible' => 1), array('id' => $selected), '%d', '%d');
}
}
WPSC_Countries::clear_cache();
wpsc_core_flush_temporary_data();
}
$previous_currency = get_option('currency_type');
//To update options
if (isset($_POST['wpsc_options'])) {
$_POST['wpsc_options'] = stripslashes_deep($_POST['wpsc_options']);
// make sure stock keeping time is a number
if (isset($_POST['wpsc_options']['wpsc_stock_keeping_time'])) {
$skt = $_POST['wpsc_options']['wpsc_stock_keeping_time'];
// I hate repeating myself
//.........这里部分代码省略.........
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:101,代码来源:settings-page.php
示例9: wpsc_get_currency_code
/**
* wpsc_get_currency_code
*
* @param does not receive anything
* @return returns the currency code used for the shop
*/
function wpsc_get_currency_code()
{
return WPSC_Countries::get_currency_code(get_option('currency_type'));
}
开发者ID:AngryBird3,项目名称:WP-e-Commerce,代码行数:10,代码来源:processing.functions.php
示例10: _wpsc_filter_control_select_country
function _wpsc_filter_control_select_country($output, $field, $args)
{
extract($field);
$country_data = WPSC_Countries::get_countries();
$options = array();
foreach ($country_data as $country) {
$isocode = $country->get_isocode();
$alternatives = array($country->get_isocode());
switch ($isocode) {
case 'US':
$alternatives[] = __('United States of America', 'wp-e-commerce');
break;
case 'GB':
$alternatives[] = __('Great Britain', 'wp-e-commerce');
$alternatives[] = __('England', 'wp-e-commerce');
$alternatives[] = __('Wales', 'wp-e-commerce');
$alternatives[] = __('UK', 'wp-e-commerce');
$alternatives[] = __('Scotland', 'wp-e-commerce');
$alternatives[] = __('Northern Ireland', 'wp-e-commerce');
break;
}
$alternatives = apply_filters('wpsc_country_alternative_spellings', $alternatives, $isocode, $country);
$options[$country->get_isocode()] = array('title' => $country->get_name(), 'attributes' => array('data-alternative-spellings' => implode(' ', $alternatives)));
}
$output .= wpsc_form_select($name, $value, $options, array('id' => $id . '-control', 'class' => 'wpsc-form-select-country'), false);
return $output;
}
开发者ID:benhuson,项目名称:WP-e-Commerce,代码行数:27,代码来源:form.php
示例11: wpsc_country_list
/**
* get a country list for checkout
*
* @param string|null $form_id
* @param deprecated|null $ajax
* @param string|null $selected_country
* @param deprecated|null $selected_region
* @param string|null $supplied_form_id
* @param boolean $shippingfields
* @return string
*/
function wpsc_country_list($form_id = null, $ajax = null, $selected_country = null, $selected_region = null, $supplied_form_id = null, $shippingfields = false)
{
global $wpdb;
$output = '';
if ($form_id != null) {
$html_form_id = "region_country_form_{$form_id}";
} else {
$html_form_id = 'region_country_form';
}
if ($shippingfields) {
$js = '';
$title = 'shippingcountry';
$id = 'shippingcountry';
} else {
$js = '';
$title = 'billingcountry';
$id = 'billingcountry';
}
if (empty($supplied_form_id)) {
$supplied_form_id = $id;
}
// 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($id, $wpsc_country->get_isocode());
}
$additional_attributes = 'data-wpsc-meta-key="' . $title . '" title="' . $title . '" ' . $js;
$output .= "<div id='{$html_form_id}'>\n\r";
$output .= wpsc_get_country_dropdown(array('id' => $supplied_form_id, 'name' => "collected_data[{$form_id}][0]", 'class' => 'current_country wpsc-visitor-meta', 'selected' => $selected_country, 'additional_attributes' => $additional_attributes, 'placeholder' => __('Please select a country', 'wp-e-commerce')));
$output .= "</div>\n\r";
return $output;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:48,代码来源:shopping_cart_functions.php
示例12: 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
示例13: get_cache
public static function get_cache($value = null, $col = 'id')
{
$function = __CLASS__ . '::' . __FUNCTION__ . '()';
$replacement = 'WPSC_Countries::get_country()';
_wpsc_deprecated_function($function, '3.8.14', $replacement);
if (defined('WPSC_LOAD_DEPRECATED') && WPSC_LOAD_DEPRECATED) {
if (is_null($value) && $col == 'id') {
$value = get_option('currency_type');
}
// note that we can't store cache by currency code, the code is used by various countries
// TODO: remove duplicate entry for Germany (Deutschland)
if (!in_array($col, array('id', 'isocode'))) {
return false;
}
return WPSC_Countries::get_country($value, WPSC_Countries::RETURN_AN_ARRAY);
}
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:17,代码来源:wpsc-country.class.php
示例14: wpsc_donations
function wpsc_donations($args = null)
{
global $wpdb;
// Args not used yet but this is ready for when it is
$args = wp_parse_args((array) $args, array());
$products = $wpdb->get_results("SELECT DISTINCT `p` . * , `m`.`meta_value` AS `special_price`\n\t\tFROM `" . $wpdb->postmeta . "` AS `m`\n\t\tJOIN `" . $wpdb->posts . "` AS `p` ON `m`.`post_id` = `p`.`ID`\n\t\tWHERE `p`.`post_parent` IN ('0')\n\t\t\tAND `m`.`meta_key` IN ('_wpsc_is_donation')\n\t\t\tAND `m`.`meta_value` IN( '1' )\n\t\tORDER BY RAND( )\n\t\tLIMIT 1", ARRAY_A);
$output = '';
if ($products != null) {
foreach ($products as $product) {
$attached_images = (array) get_posts(array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $product['ID'], 'orderby' => 'menu_order', 'order' => 'ASC'));
$attached_image = $attached_images[0];
$output .= "<div class='wpsc_product_donation'>";
if ($attached_image->ID > 0) {
$output .= "<img src='" . wpsc_product_image($attached_image->ID, get_option('product_image_width'), get_option('product_image_height')) . "' title='" . $product['post_title'] . "' alt='" . esc_attr($product['post_title']) . "' /><br />";
}
// Get currency options
$currency_sign_location = get_option('currency_sign_location');
$currency_type = get_option('currency_type');
WPSC_Countries::get_currency_symbol($currency_type);
$price = get_post_meta($product['ID'], '_wpsc_price', true);
// Output
$output .= "<strong>" . $product['post_title'] . "</strong><br />";
$output .= $product['post_content'] . "<br />";
$output .= "<form class='product_form' name='donation_widget_" . $product['ID'] . "' method='post' action='' id='donation_widget_" . $product['ID'] . "'>";
$output .= "<input type='hidden' name='product_id' value='" . $product['ID'] . "'/>";
$output .= "<input type='hidden' name='item' value='" . $product['ID'] . "' />";
$output .= "<input type='hidden' name='wpsc_ajax_action' value='add_to_cart' />";
$output .= "<label for='donation_widget_price_" . $product['ID'] . "'>" . __('Donation', 'wp-e-commerce') . ":</label> {$currency_symbol}<input type='text' id='donation_widget_price_" . $product['ID'] . "' name='donation_price' value='" . esc_attr(number_format($price, 2)) . "' size='6' /><br />";
$output .= "<input type='submit' id='donation_widget_" . $product['ID'] . "_submit_button' name='Buy' class='wpsc_buy_button' value='" . __('Add To Cart', 'wp-e-commerce') . "' />";
$output .= "</form>";
$output .= "</div>";
}
} else {
$output = '';
}
echo $output;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:37,代码来源:donations_widget.php
示例15: set_customer_details
public function set_customer_details()
{
$_POST['wpsc_checkout_details'] = array();
$_GET['amazon_reference_id'] = sanitize_text_field($_POST['amazon_reference_id']);
try {
if (!$this->reference_id) {
throw new Exception(__('An Amazon payment method was not chosen.', 'wpsc'));
}
if (is_null($this->purchase_log)) {
$log = _wpsc_get_current_controller()->get_purchase_log();
wpsc_update_customer_meta('current_purchase_log_id', $log->get('id'));
$this->set_purchase_log($log);
}
global $wpsc_cart;
// Update order reference with amounts
$response = $this->api_request(array('Action' => 'SetOrderReferenceDetails', 'AmazonOrderReferenceId' => $this->reference_id, 'OrderReferenceAttributes.OrderTotal.Amount' => $wpsc_cart->calculate_total_price(), 'OrderReferenceAttributes.OrderTotal.CurrencyCode' => strtoupper($this->get_currency_code()), 'OrderReferenceAttributes.SellerNote' => sprintf(__('Order %s from %s.', 'wpsc'), $this->purchase_log->get('id'), urlencode(remove_accents(wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)))), 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId' => $this->purchase_log->get('id'), 'OrderReferenceAttributes.SellerOrderAttributes.StoreName' => remove_accents(wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)), 'OrderReferenceAttributes.PlatformId' => 'A2Z8DY3R4G08IM'));
if (is_wp_error($response)) {
throw new Exception($response->get_error_message());
}
if (isset($response['Error']['Message'])) {
throw new Exception($response['Error']['Message']);
}
$response = $this->api_request(array('Action' => 'GetOrderReferenceDetails', 'AmazonOrderReferenceId' => $this->reference_id));
if (is_wp_error($response)) {
throw new Exception($response->get_error_message());
}
if (!isset($response['GetOrderReferenceDetailsResult']['OrderReferenceDetails']['Destination']['PhysicalDestination'])) {
return;
}
$address = $response['GetOrderReferenceDetailsResult']['OrderReferenceDetails']['Destination']['PhysicalDestination'];
remove_action('wpsc_checkout_get_fields', '__return_empty_array');
add_filter('wpsc_validate_form', '__return_true');
$form = WPSC_Checkout_Form::get();
$fields = $form->get_fields();
foreach ($fields as $field) {
switch ($field->unique_name) {
case 'shippingstate':
$_POST['wpsc_checkout_details'][$field->id] = WPSC_Countries::get_region_id($address['CountryCode'], $address['StateOrRegion']);
break;
case 'shippingcountry':
$_POST['wpsc_checkout_details'][$field->id] = $address['CountryCode'];
break;
case 'shippingpostcode':
$_POST['wpsc_checkout_details'][$field->id] = $address['PostalCode'];
break;
case 'shippingcity':
$_POST['wpsc_checkout_details'][$field->id] = $address['City'];
break;
}
}
} catch (Exception $e) {
WPSC_Message_Collection::get_instance()->add($e->getMessage(), 'error', 'main', 'flash');
return;
}
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:55,代码来源:amazon-payments.php
示例16: 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
示例17: wpec_taxes_get_region_code_by_id
/**
* @description: wpec_taxes_get_region_code_by_id - given an id this funciton will
* return the region code.
* @param: id - a region id
* @return: int or false
* */
function wpec_taxes_get_region_code_by_id($region)
{
$region_code = false;
if (!empty($region)) {
$country_id = WPSC_Countries::get_country_id_by_region_id($region);
if ($country_id) {
$wpsc_country = new WPSC_Country($country_id);
}
if (isset($wpsc_country)) {
$wpsc_region = $wpsc_country->get_region($region);
if ($wpsc_region) {
$region_code = $wpsc_region->get_code();
}
}
}
return $region_code;
}
开发者ID:parkesma,项目名称:WP-e-Commerce,代码行数:23,代码来源:taxes.class.php
示例18: wpsc_admin_category_forms_edit
//.........这里部分代码省略.........
</span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top">
<label for="image"><?php
esc_html_e('Display Category Template Tag', 'wpsc');
?>
</label>
</th>
<td>
<code><?php echo wpsc_display_products_page( array( 'category_url_name' => '<?php
echo $category["slug"];
?>
' ) ); ?></code><br />
<span class="description"><?php
esc_html_e('Template tags are used to display a particular category or group within your theme / template.', 'wpsc');
?>
</span>
</td>
</tr>
<!-- START OF TARGET MARKET SELECTION -->
<tr>
<td colspan="2">
<h4><?php
esc_html_e('Target Market Restrictions', 'wpsc');
?>
</h4>
</td>
</tr>
<?php
$countrylist = WPSC_Countries::get_countries_array(true, true);
$selectedCountries = wpsc_get_meta($category_id, 'target_market', 'wpsc_category');
?>
<tr>
<th scope="row" valign="top">
<label for="image"><?php
esc_html_e('Target Markets', 'wpsc');
?>
</label>
</th>
<td>
<?php
if (wpsc_is_suhosin_enabled()) {
?>
<em><?php
esc_html_e('The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature, then disable the suhosin extension. If you can not do this, you will need to contact your hosting provider.', 'wpsc');
?>
</em>
<?php
} else {
?>
<span><?php
esc_html_e('Select', 'wpsc');
?>
: <a href='' class='wpsc_select_all'><?php
esc_html_e('All', 'wpsc');
?>
</a> <a href='' class='wpsc_select_none'><?php
esc_html_e('None', 'wpsc');
?>
</a></span><br />
<div id='resizeable' class='ui-widget-content multiple-select'>
<?php
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:67,代码来源:save-data.functions.php
示例19: display
public function display()
{
global $wpdb;
?>
<h3><?php
echo esc_html_e('General Settings', 'wpsc');
?>
</h3>
<table class='wpsc_options form-table'>
<tr>
<th scope="row"><label for="wpsc-base-country-drop-down"><?php
esc_html_e('Base Country/Region', 'wpsc');
?>
</label></th>
<td>
<?php
wpsc_country_dropdown(array('id' => 'wpsc-base-country-drop-down', 'name' => 'wpsc_options[base_country]', 'selected' => get_option('base_country'), 'include_invisible' => true));
?>
<span id='wpsc-base-region-drop-down'>
<?php
$this->display_region_drop_down();
?>
<img src="<?php
echo esc_url(wpsc_get_ajax_spinner());
?>
" class="ajax-feedback" title="" alt="" />
</span>
<p class='description'><?php
esc_html_e('Select your primary business location.', 'wpsc');
?>
</p>
</td>
</tr>
<?php
/* START OF TARGET MARKET SELECTION */
$countrylist = WPSC_Countries::get_countries_array(true, true);
?>
<tr>
<th scope="row">
<?php
esc_html_e('Target Markets', 'wpsc');
?>
</th>
<td>
<?php
// check for the suhosin module
if (wpsc_is_suhosin_enabled()) {
echo "<em>" . __("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.", 'wpsc') . "</em>";
} else {
?>
<span>
<?php
printf(__('Select: <a href="%1$s" class="wpsc-select-all" title="All">All</a> <a href="%2$s" class="wpsc-select-none" title="None">None</a>', 'wpsc'), esc_url(add_query_arg(array('selected_all' => 'all'))), esc_url(add_query_arg(array('selected_all' => 'none'))));
?>
</span><br />
<div id='wpsc-target-markets' class='ui-widget-content multiple-select'>
<?php
foreach ((array) $countrylist as $country) {
?>
<?php
if ($country['visible'] == 1) {
?>
<input type='checkbox' id="countrylist2-<?php
echo $country['id'];
?>
" name='countrylist2[]' value='<?php
echo $country['id'];
?>
' checked='checked' />
<label for="countrylist2-<?php
echo $country['id'];
?>
"><?php
esc_html_e($country['country']);
?>
</label><br />
<?php
}
|
请发表评论