本文整理汇总了PHP中Lookup::countries方法的典型用法代码示例。如果您正苦于以下问题:PHP Lookup::countries方法的具体用法?PHP Lookup::countries怎么用?PHP Lookup::countries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lookup
的用法示例。
在下文中一共展示了Lookup::countries方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: country
static function country($data)
{
$countries = Lookup::countries();
if (isset($countries[$data->country])) {
return $countries[$data->country]['name'];
}
return $data->country;
}
示例2: manager
//.........这里部分代码省略.........
$Customer = new ShoppCustomer((int) $_GET['customerid']);
if ((int) $Customer->id > 0) {
$Purchase->copydata($Customer);
$Purchase->customer = $Customer->id;
$Purchase->save();
} else {
$this->notice(__('The selected customer was not found.', 'Shopp'), 'error');
}
}
if (isset($_POST['save-item']) && !empty($_POST['lineid'])) {
// Create a cart representation of the order to recalculate order totals
$Cart = new ShoppCart();
foreach ($Purchase->purchased as $OrderItem) {
$CartItem = new Item($OrderItem);
$Cart->contents[$OrderItem->id] = $CartItem;
}
$purchasedid = (int) $_POST['lineid'];
$Purchased = $Purchase->purchased[$purchasedid];
if ($Purchased->id) {
$override_total = Shopp::floatval($_POST['total']) != $Purchased->total;
// Override total
$Item = $Cart->contents[$purchasedid];
$Item->quantity($_POST['quantity']);
$Item->unitprice = Shopp::floatval($_POST['unitprice']);
$Item->retotal();
$Purchased->quantity = $Item->quantity;
$Purchased->unitprice = $Item->unitprice;
$Purchased->unittax = $Item->unittax;
$Purchased->total = $Item->total;
if ($override_total) {
$Purchased->total = Shopp::floatval($_POST['total']);
}
$Purchased->save();
}
$Cart->retotal = true;
$Cart->totals();
$Purchase->copydata($Cart->Totals);
$Purchase->save();
}
if (isset($_POST['charge']) && $Gateway && $Gateway->captures) {
if (!current_user_can('shopp_capture')) {
wp_die(__('You do not have sufficient permissions to carry out this action.', 'Shopp'));
}
$user = wp_get_current_user();
shopp_add_order_event($Purchase->id, 'capture', array('txnid' => $Purchase->txnid, 'gateway' => $Purchase->gateway, 'amount' => $Purchase->capturable(), 'user' => $user->ID));
$Purchase->load_events();
}
$base = shopp_setting('base_operations');
$targets = shopp_setting('target_markets');
$countries = array('' => ' ');
$countrydata = Lookup::countries();
foreach ($countrydata as $iso => $c) {
if ($base['country'] == $iso) {
$base_region = $c['region'];
}
$countries[$iso] = $c['name'];
}
$Purchase->_countries = $countries;
$regions = Lookup::country_zones();
$Purchase->_billing_states = array_merge(array('' => ' '), (array) $regions[$Purchase->country]);
$Purchase->_shipping_states = array_merge(array('' => ' '), (array) $regions[$Purchase->shipcountry]);
// Setup shipping carriers menu and JS data
$carriers_menu = $carriers_json = array();
$shipping_carriers = (array) shopp_setting('shipping_carriers');
// The store-preferred shipping carriers
$shipcarriers = Lookup::shipcarriers();
// The full list of available shipping carriers
$notrack = Shopp::__('No Tracking');
// No tracking label
$default = get_user_meta(get_current_user_id(), 'shopp_shipping_carrier', true);
if (isset($shipcarriers[$default])) {
$carriers_menu[$default] = $shipcarriers[$default]->name;
$carriers_json[$default] = array($shipcarriers[$default]->name, $shipcarriers[$default]->trackpattern);
} else {
$carriers_menu['NOTRACKING'] = $notrack;
$carriers_json['NOTRACKING'] = array($notrack, false);
}
$serviceareas = array('*', $base['country']);
foreach ($shipcarriers as $code => $carrier) {
if ($code == $default) {
continue;
}
if (!empty($shipping_carriers) && !in_array($code, $shipping_carriers)) {
continue;
}
if (!in_array($carrier->areas, $serviceareas)) {
continue;
}
$carriers_menu[$code] = $carrier->name;
$carriers_json[$code] = array($carrier->name, $carrier->trackpattern);
}
if (isset($shipcarriers[$default])) {
$carriers_menu['NOTRACKING'] = $notrack;
$carriers_json['NOTRACKING'] = array($notrack, false);
}
if (empty($statusLabels)) {
$statusLabels = array('');
}
include $this->ui('order.php');
}
示例3: setup
/**
* Displays the General Settings screen and processes updates
*
* @author Jonathan Davis
* @since 1.0
*
* @return void
**/
public function setup()
{
if (!current_user_can('shopp_settings')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// Welcome screen handling
if (!empty($_POST['setup'])) {
$_POST['settings']['display_welcome'] = 'off';
shopp_set_formsettings();
}
$country = isset($_POST['settings']) && isset($_POST['settings']['base_operations']) ? $_POST['settings']['base_operations']['country'] : '';
$countries = array();
$countrydata = Lookup::countries();
$country_zones = Lookup::country_zones();
foreach ($countrydata as $iso => $c) {
if ($country == $iso) {
$base_region = $c['region'];
}
$countries[$iso] = $c['name'];
}
// Save settings
if (!empty($_POST['save']) && isset($_POST['settings'])) {
check_admin_referer('shopp-setup');
if (isset($_POST['settings']['base_operations'])) {
$baseop =& $_POST['settings']['base_operations'];
$zone = isset($baseop['zone']) && isset($country_zones[$country]) && isset($country_zones[$country][$baseop['zone']]) ? $baseop['zone'] : false;
if (isset($countrydata[$country])) {
$baseop = $countrydata[$country];
}
$baseop['country'] = $country;
$baseop['zone'] = $zone;
$baseop['currency']['format'] = scan_money_format($baseop['currency']['format']);
if (is_array($baseop['currency']['format'])) {
$fields = array_keys($baseop['currency']['format']);
foreach ($fields as $field) {
if (isset($baseop['currency'][$field])) {
$baseop['currency']['format'][$field] = $baseop['currency'][$field];
}
}
}
shopp_set_setting('tax_inclusive', in_array($country, Lookup::country_inclusive_taxes()) ? 'on' : 'off');
}
if (!isset($_POST['settings']['target_markets'])) {
asort($_POST['settings']['target_markets']);
}
shopp_set_formsettings();
$updated = __('Shopp settings saved.', 'Shopp');
}
$operations = shopp_setting('base_operations');
if (isset($country_zones[$operations['country']])) {
$zones = $country_zones[$operations['country']];
}
$targets = shopp_setting('target_markets');
if (is_array($targets)) {
$targets = array_map('stripslashes', $targets);
}
if (!$targets) {
$targets = array();
}
include $this->ui('setup.php');
}
示例4: editor
/**
* Interface processor for the customer editor
*
* Handles rendering the interface, processing updated customer details
* and handing saving them back to the database
*
* @return void
**/
function editor () {
global $Ecart,$Customer;
$db =& DB::get();
if ( !(is_ecart_userlevel() || current_user_can('ecart_customers')) )
wp_die(__('You do not have sufficient permissions to access this page.'));
if ($_GET['id'] != "new") {
$Customer = new Customer($_GET['id']);
$Customer->Billing = new Billing($Customer->id,'customer');
$Customer->Shipping = new Shipping($Customer->id,'customer');
if (empty($Customer->id))
wp_die(__('The requested customer record does not exist.','Ecart'));
} else $Customer = new Customer();
if (empty($Customer->info->meta)) remove_meta_box('customer-info','ecart_page_ecart-customers','normal');
$purchase_table = DatabaseObject::tablename(Purchase::$table);
$r = $db->query("SELECT count(id) AS purchases,SUM(total) AS total FROM $purchase_table WHERE customer='$Customer->id' LIMIT 1");
$Customer->orders = $r->purchases;
$Customer->total = $r->total;
$countries = array(''=>' ');
$countrydata = Lookup::countries();
foreach ($countrydata as $iso => $c) {
if (isset($_POST['settings']) && $_POST['settings']['base_operations']['country'] == $iso)
$base_region = $c['region'];
$countries[$iso] = $c['name'];
}
$Customer->countries = $countries;
$regions = Lookup::country_zones();
$Customer->billing_states = array_merge(array(''=>' '),(array)$regions[$Customer->Billing->country]);
$Customer->shipping_states = array_merge(array(''=>' '),(array)$regions[$Customer->Shipping->country]);
include(ECART_ADMIN_PATH."/customers/editor.php");
}
示例5: shiprates
//.........这里部分代码省略.........
$active[$module] = array();
}
$active[$module][(int) $id] = true;
shopp_set_setting('active_shipping', $active);
$this->notice(Shopp::__('Shipping settings saved.'));
}
}
}
$Shipping->settings();
// Load all installed shipping modules for settings UIs
$Shipping->ui();
// Setup setting UIs
$installed = array();
$shiprates = array();
// Registry for activated shipping rate modules
$settings = array();
// Registry of loaded settings for table-based shipping rates for JS
foreach ($Shipping->active as $name => $module) {
if (version_compare($Shipping->modules[$name]->since, '1.2') == -1) {
continue;
}
// Skip 1.1 modules, they are incompatible
$default_name = strtolower($name);
$fullname = $module->methods();
$installed[$name] = $fullname;
if ($module->ui->tables) {
$defaults[$default_name] = $module->ui->settings();
$defaults[$default_name]['name'] = $fullname;
$defaults[$default_name]['label'] = __('Shipping Method', 'Shopp');
}
if (array_key_exists($name, $active)) {
$ModuleSetting = $active[$name];
} else {
continue;
}
// Not an activated shipping module, go to the next one
// Setup shipping service shipping rate entries and settings
if (!is_array($ModuleSetting)) {
$shiprates[$name] = $name;
continue;
}
// Setup shipping calcualtor shipping rate entries and settings
foreach ($ModuleSetting as $id => $m) {
$setting = "{$name}-{$id}";
$shiprates[$setting] = $name;
$settings[$setting] = shopp_setting($setting);
$settings[$setting]['id'] = $setting;
$settings[$setting] = array_merge($defaults[$default_name], $settings[$setting]);
if (isset($settings[$setting]['table'])) {
usort($settings[$setting]['table'], array('ShippingFramework', '_sorttier'));
foreach ($settings[$setting]['table'] as &$r) {
if (isset($r['tiers'])) {
usort($r['tiers'], array('ShippingFramework', '_sorttier'));
}
}
}
}
}
if (isset($_REQUEST['id'])) {
$edit = $_REQUEST['id'];
$id = false;
if (strpos($edit, '-') !== false) {
list($module, $id) = explode('-', $edit);
} else {
$module = $edit;
}
if (isset($Shipping->active[$module])) {
$Shipper = $Shipping->get($module);
if (!$Shipper->singular) {
$Shipper->setting($id);
$Shipper->initui($Shipping->modules[$module]->name);
// Re-init setting UI with loaded settings
}
$editor = $Shipper->ui();
}
}
asort($installed);
$countrydata = Lookup::countries();
$countries = $regionmap = $postcodes = array();
$postcodedata = Lookup::postcodes();
foreach ($countrydata as $code => $country) {
$countries[$code] = $country['name'];
if (!isset($regionmap[$country['region']])) {
$regionmap[$country['region']] = array();
}
$regionmap[$country['region']][] = $code;
if (isset($postcodedata[$code])) {
if (!isset($postcodes[$code])) {
$postcodes[$code] = array();
}
$postcodes[$code] = true;
}
}
unset($countrydata);
unset($postcodedata);
$lookup = array('regions' => array_merge(array('*' => __('Anywhere', 'Shopp')), Lookup::regions()), 'regionmap' => $regionmap, 'countries' => $countries, 'areas' => Lookup::country_areas(), 'zones' => Lookup::country_zones(), 'postcodes' => $postcodes);
$ShippingTemplates = new TemplateShippingUI();
add_action('shopp_shipping_module_settings', array($Shipping, 'templates'));
include $this->ui('shiprates.php');
}
示例6: location_menu
public function location_menu($destination = false, $row = 0, $module = false)
{
if (!$module) {
$module = $this->module;
}
$menuarrow = ' ▾';
$tab = str_repeat('⋅', 3) . ' ';
$regions = Lookup::regions();
$countries = Lookup::countries();
$regional_countries = array();
$country_areas = array();
$country_zones = array();
$postcode = false;
$subregions = isset($_POST[$module]['table'][$row]['subregions']);
$selection = array();
$selected = array('region' => '*', 'country' => '', 'area' => '', 'zone' => '');
if (strpos($destination, ',') !== false) {
$selection = explode(',', $destination);
} else {
$selection = array($destination);
}
if ($subregions && isset($_POST[$module]['table'][$row]['destination'])) {
$selection = explode(',', $_POST[$module]['table'][$row]['destination']);
}
if (!is_array($selection)) {
$selection = array($selection);
}
$keys = array_slice(array_keys($selected), 0, count($selection));
$selected = array_merge($selected, array_combine($keys, $selection));
$regional_countries = array_filter($countries, create_function('$c', 'return (\'' . $selected['region'] . '\' === (string)$c[\'region\']);'));
if (!empty($selected['country'])) {
$ca = Lookup::country_areas();
if (isset($ca[$selected['country']])) {
$country_areas = $ca[$selected['country']];
}
$cz = Lookup::country_zones();
if (isset($cz[$selected['country']])) {
$country_zones = $cz[$selected['country']];
}
}
$options = array('*' => __('Anywhere', 'Shopp'));
foreach ($regions as $index => $region) {
if ($index == $selected['region'] && !empty($regional_countries) && ($subregions || !empty($selected['country']))) {
$options[$index] = $region . $menuarrow;
foreach ($regional_countries as $country => $country_data) {
$country_name = $country_data['name'];
if ($country == $selected['country']) {
$postcodes = Lookup::postcodes();
$postcode = isset($postcodes[$selected['country']]);
if (!empty($country_areas) && ($subregions || !empty($selected['area']))) {
$options["{$index},{$country}"] = $country_name . $menuarrow;
$areas = array_keys($country_areas);
foreach ($areas as $area => $area_name) {
if ((string) $area == (string) $selected['area']) {
$zones = array_flip($country_areas[$area_name]);
$zones = array_intersect_key($country_zones, $zones);
$group_name = $area_name . $menuarrow;
$options[$group_name] = array();
// Setup option group for area zones
if (empty($selected['zone'])) {
$selected['zone'] = key($zones);
}
foreach ($zones as $zone => $zone_name) {
$options[$group_name]["{$index},{$country},{$area},{$zone}"] = $zone_name . ', ' . substr($country, 0, 2);
}
// end foreach($country_zones)
} else {
$options["{$index},{$country},{$area}"] = str_repeat(' ', 2) . $area_name;
}
}
// end foreach($areas)
} elseif (!empty($country_zones) && ($subregions || !empty($selected['area']))) {
$options[$country_name] = array();
if (empty($selected['area'])) {
$selected['area'] = key($country_zones);
}
foreach ($country_zones as $zone => $zone_name) {
$options[$country_name]["{$index},{$country},{$zone}"] = $zone_name . ', ' . substr($country, 0, 2);
}
// end foreach($country_zones)
} else {
$options["{$index},{$country}"] = $country_name;
}
} else {
$options["{$index},{$country}"] = $tab . $country_name;
}
}
// end foreach ($regional_countries)
} else {
$options[$index] = $region;
}
}
// end foreach ($regions)
$selected = array_filter($selected, create_function('$i', 'return (\'\' != $i);'));
$selection = join(',', $selected);
return array('options' => $options, 'selection' => $selection, 'postcode' => $postcode);
}
示例7: tag
//.........这里部分代码省略.........
$allowed_types = array("text","password","hidden","checkbox","radio");
$type = in_array($type,$allowed_types)?$type:'hidden';
return '<input type="'.$type.'" name="info['.$options['name'].']" id="customer-info-'.sanitize_title_with_dashes($options['name']).'"'.inputattrs($options).' />';
break;
// SHIPPING TAGS
case "shipping": return $Order->Shipping;
case "shipping-address":
if ($options['mode'] == "value") return $Order->Shipping->address;
if (!empty($Order->Shipping->address))
$options['value'] = $Order->Shipping->address;
return '<input type="text" name="shipping[address]" id="shipping-address" '.inputattrs($options).' />';
break;
case "shipping-xaddress":
if ($options['mode'] == "value") return $Order->Shipping->xaddress;
if (!empty($Order->Shipping->xaddress))
$options['value'] = $Order->Shipping->xaddress;
return '<input type="text" name="shipping[xaddress]" id="shipping-xaddress" '.inputattrs($options).' />';
break;
case "shipping-city":
if ($options['mode'] == "value") return $Order->Shipping->city;
if (!empty($Order->Shipping->city))
$options['value'] = $Order->Shipping->city;
return '<input type="text" name="shipping[city]" id="shipping-city" '.inputattrs($options).' />';
break;
case "shipping-province":
case "shipping-state":
if ($options['mode'] == "value") return $Order->Shipping->state;
if (!isset($options['selected'])) $options['selected'] = false;
if (!empty($Order->Shipping->state)) {
$options['selected'] = $Order->Shipping->state;
$options['value'] = $Order->Shipping->state;
}
$countries = Lookup::countries();
$output = false;
$country = $base['country'];
if (!empty($Order->Shipping->country))
$country = $Order->Shipping->country;
if (!array_key_exists($country,$countries)) $country = key($countries);
if (empty($options['type'])) $options['type'] = "menu";
$regions = Lookup::country_zones();
$states = $regions[$country];
if (is_array($states) && $options['type'] == "menu") {
$label = (!empty($options['label']))?$options['label']:'';
$output = '<select name="shipping[state]" id="shipping-state" '.inputattrs($options,$select_attrs).'>';
$output .= '<option value="" selected="selected">'.$label.'</option>';
$output .= menuoptions($states,$options['selected'],true);
$output .= '</select>';
} else if ($options['type'] == "menu") {
$options['disabled'] = 'disabled';
$options['class'] = ($options['class']?" ":null).'unavailable';
$label = (!empty($options['label']))?$options['label']:'';
$output = '<select name="shipping[state]" id="shipping-state" '.inputattrs($options,$select_attrs).'></select>';
} else $output .= '<input type="text" name="shipping[state]" id="shipping-state" '.inputattrs($options).'/>';
return $output;
break;
case "shipping-postcode":
if ($options['mode'] == "value") return $Order->Shipping->postcode;
if (!empty($Order->Shipping->postcode))
$options['value'] = $Order->Shipping->postcode;
return '<input type="text" name="shipping[postcode]" id="shipping-postcode" '.inputattrs($options).' />'; break;
case "shipping-country":
if ($options['mode'] == "value") return $Order->Shipping->country;
$base = $Ecart->Settings->get('base_operations');
if (!empty($Order->Shipping->country))
示例8: general
/**
* Displays the General Settings screen and processes updates
*
* @since 1.0
*
* @return void
**/
function general () {
global $Ecart;
if ( !(current_user_can('manage_options') && current_user_can('ecart_settings')) )
wp_die(__('You do not have sufficient permissions to access this page.'));
$updatekey = $Ecart->Settings->get('updatekey');
$activated = ($updatekey[0] == "1");
$type = "text";
$key = $updatekey[1];
if (isset($updatekey[2]) && $updatekey[2] == "dev") {
$type = "password";
$key = preg_replace('/\w/','?',$key);
}
$country = (isset($_POST['settings']))?$_POST['settings']['base_operations']['country']:'';
$countries = array();
$countrydata = Lookup::countries();
foreach ($countrydata as $iso => $c) {
if (isset($_POST['settings']) && $_POST['settings']['base_operations']['country'] == $iso)
$base_region = $c['region'];
$countries[$iso] = $c['name'];
}
if (!empty($_POST['setup'])) {
$_POST['settings']['display_welcome'] = "off";
$this->settings_save();
}
if (!empty($_POST['save'])) {
check_admin_referer('ecart-settings-general');
$vat_countries = Lookup::vat_countries();
$zone = $_POST['settings']['base_operations']['zone'];
$_POST['settings']['base_operations'] = $countrydata[$_POST['settings']['base_operations']['country']];
$_POST['settings']['base_operations']['country'] = $country;
$_POST['settings']['base_operations']['zone'] = $zone;
$_POST['settings']['base_operations']['currency']['format'] =
scan_money_format($_POST['settings']['base_operations']['currency']['format']);
if (in_array($_POST['settings']['base_operations']['country'],$vat_countries))
$_POST['settings']['base_operations']['vat'] = true;
else $_POST['settings']['base_operations']['vat'] = false;
if (!isset($_POST['settings']['target_markets']))
asort($_POST['settings']['target_markets']);
$this->settings_save();
$updated = __('Ecart settings saved.', 'Ecart');
}
$operations = $Ecart->Settings->get('base_operations');
if (!empty($operations['zone'])) {
$zones = Lookup::country_zones();
$zones = $zones[$operations['country']];
}
$targets = $Ecart->Settings->get('target_markets');
if (!$targets) $targets = array();
$statusLabels = $Ecart->Settings->get('order_status');
include(ECART_ADMIN_PATH."/settings/settings.php");
}
示例9: locate
/**
* Sets the address location for calculating tax and shipping estimates
*
* @author Jonathan Davis
* @since 1.1
*
* @return void
**/
public function locate($data = false)
{
$base = shopp_setting('base_operations');
$markets = shopp_setting('target_markets');
$countries = Lookup::countries();
$regions = Lookup::regions();
if ($data) {
$this->updates($data);
}
if (empty($this->country)) {
// If the target markets are set to single country, use that target as default country
// otherwise default to the base of operations for tax and shipping estimates
if (1 == count($markets)) {
$this->country = key($markets);
} else {
$this->country = $base['country'];
}
}
// Update state if postcode changes for tax updates
if (isset($this->postcode)) {
$this->postmap();
}
$this->region = false;
if (isset($countries[$this->country]) && isset($regions[$countries[$this->country]['region']])) {
$this->region = $regions[$countries[$this->country]['region']];
}
}
示例10: editor
/**
* Interface processor for the customer editor
*
* Handles rendering the interface, processing updated customer details
* and handing saving them back to the database
*
* @author Jonathan Davis
* @return void
**/
public function editor()
{
if (!current_user_can('shopp_customers')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
if ($_GET['id'] != "new") {
$Customer = new ShoppCustomer($_GET['id']);
$Customer->Billing = new BillingAddress($Customer->id, 'customer');
$Customer->Shipping = new ShippingAddress($Customer->id, 'customer');
if (empty($Customer->id)) {
wp_die(__('The requested customer record does not exist.', 'Shopp'));
}
} else {
$Customer = new ShoppCustomer();
}
if (empty($Customer->info->meta)) {
remove_meta_box('customer-info', 'shopp_page_shopp-customers', 'normal');
}
if ($Customer->id > 0) {
$purchase_table = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$r = sDB::query("SELECT count(id) AS purchases,SUM(total) AS total FROM {$purchase_table} WHERE customer='{$Customer->id}' LIMIT 1");
$Customer->orders = $r->purchases;
$Customer->total = $r->total;
}
$countries = array('' => ' ');
$countrydata = Lookup::countries();
foreach ($countrydata as $iso => $c) {
if (isset($_POST['settings']) && $_POST['settings']['base_operations']['country'] == $iso) {
$base_region = $c['region'];
}
$countries[$iso] = $c['name'];
}
$Customer->countries = $countries;
$regions = Lookup::country_zones();
$Customer->billing_states = array_merge(array('' => ' '), (array) $regions[$Customer->Billing->country]);
$Customer->shipping_states = array_merge(array('' => ' '), (array) $regions[$Customer->Shipping->country]);
include $this->ui('editor.php');
}
示例11: upgrade_120
public function upgrade_120()
{
// 1.2 schema changes
$db_version = ShoppSettings::dbversion();
if ($db_version < 1120) {
$this->upschema('schema-120.sql');
}
global $wpdb;
// Clear the shopping session table
$shopping_table = ShoppDatabaseObject::tablename('shopping');
sDB::query("DELETE FROM {$shopping_table}");
if ($db_version <= 1140) {
$summary_table = ShoppDatabaseObject::tablename('summary');
// Force summaries to rebuild
sDB::query("UPDATE {$summary_table} SET modified='0000-00-00 00:00:01'");
}
$purchase_table = ShoppDatabaseObject::tablename('purchase');
sDB::query("UPDATE {$purchase_table} SET txnstatus='captured' WHERE txnstatus='CHARGED'");
sDB::query("UPDATE {$purchase_table} SET txnstatus='voided' WHERE txnstatus='VOID'");
if ($db_version <= 1130) {
// Move settings to meta table
$meta_table = ShoppDatabaseObject::tablename('meta');
$setting_table = ShoppDatabaseObject::tablename('setting');
sDB::query("INSERT INTO {$meta_table} (context, type, name, value, created, modified) SELECT 'shopp', 'setting', name, value, created, modified FROM {$setting_table}");
// Clean up unnecessary duplicate settings
shopp_rmv_setting('data_model');
shopp_rmv_setting('updates');
shopp_rmv_setting('shopp_setup');
shopp_rmv_setting('maintenance');
// Re-load the Shopp settings registry
ShoppSettings()->load();
shopp_set_setting('maintenance', 'on');
$db_version = intval(shopp_setting('db_version'));
// Force inventory in 1.2 on to mimic 1.1 behavior (inventory tracking always on)
shopp_set_setting('inventory', 'on');
// Convert Shopp 1.1.x shipping settings to Shopp 1.2-compatible settings
$active_shipping = array();
$regions = Lookup::regions();
$countries = Lookup::countries();
$areas = Lookup::country_areas();
$calcnaming = array('FlatRates::order' => 'OrderRates', 'FlatRates::item' => 'ItemRates', 'FreeOption' => 'FreeOption', 'ItemQuantity::range' => 'ItemQuantity', 'OrderAmount::range' => 'OrderAmount', 'OrderWeight::range' => 'OrderWeight');
$shipping_rates = shopp_setting('shipping_rates');
foreach ((array) $shipping_rates as $id => $old) {
if (isset($calcnaming[$old['method']])) {
// Add to active setting registry for that calculator class
$calcname = $calcnaming[$old['method']];
if (!isset(${$calcname}) && !is_array(${$calcname})) {
${$calcname} = array();
}
${$calcname}[] = true;
$active_shipping[$calcname] = ${$calcname};
// Define the setting name
$settingid = end(array_keys(${$calcname}));
$setting_name = $calcname . '-' . $settingid;
} else {
// Not a calculator, must be a shipping rate provider module, add it to the active roster
$active_shipping[$old['name']] = true;
continue;
}
$new = array();
$new['label'] = $old['name'];
list($new['mindelivery'], $new['maxdelivery']) = explode('-', $old['delivery']);
$new['fallback'] = 'off';
// Not used in legacy settings
$oldkeys = array_keys($old);
$old_destinations = array_diff($oldkeys, array('name', 'delivery', 'method', 'max'));
$table = array();
foreach ($old_destinations as $old_dest) {
$_ = array();
if ('Worldwide' == $old_dest) {
$d = '*';
}
$region = array_search($old_dest, $regions);
if (false !== $region) {
$d = "{$region}";
}
if (isset($countries[$old_dest])) {
$country = $countries[$old_dest];
$region = $country['region'];
$d = "{$region}, {$old_dest}";
}
foreach ($areas as $countrykey => $countryarea) {
$areakeys = array_keys($countryarea);
$area = array_search($old_dest, $areakeys);
if (false !== $area) {
$country = $countrykey;
$region = $countries[$countrykey]['region'];
$area = $areakeys[$area];
$d = "{$region}, {$country}, {$area}";
break;
}
}
$_['destination'] = $d;
$_['postcode'] = '*';
// Postcodes are new in 1.2, hardcode to wildcard
if (isset($old['max']) && !empty($old['max'])) {
// Capture tiered rates
$_['tiers'] = array();
$prior = 1;
foreach ($old['max'] as $index => $oldthreshold) {
//.........这里部分代码省略.........
示例12: billmate_transaction
function billmate_transaction($add_order = false)
{
global $Shopp;
$Shopping =& $Shopp->Shopping;
$Order =& $Shopp->Order;
if (empty($_POST)) {
$_POST = $_GET;
}
$pno = '';
$eid = (int) $this->settings['merchantid'];
$key = $this->settings['cardpaysecret'];
$ssl = true;
$debug = false;
$k = new BillMate($eid, $key, $ssl, $debug);
$Customer = $this->Order->Customer;
$Billing = $this->Order->Billing;
$Shipping = $this->Order->Shipping;
$country = $zone = $locale = $global = false;
$country = $Billing->country;
$country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
$ship_address = $bill_address = array();
$countries = Lookup::countries();
//$countryData = BillmateCountry::getCountryData($Shipping->country);
$countryData = BillmateCountry::getSwedenData();
$ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countries[$Shipping->country]['name']);
$bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countries[$Billing->country]['name']);
foreach ($ship_address as $key => $col) {
$ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
}
foreach ($bill_address as $key => $col) {
$bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
}
extract($countryData);
$goods_list = array();
$taxrate = 0;
foreach ($this->Order->Cart as $item) {
// echo links for the items
$flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
$taxrate = $taxrate == 0 ? $item->taxrate : $taxrate;
$goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => (double) round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
}
if ($this->Order->Cart->Totals->discount > 0) {
$rate = (100 + $taxrate * 100) / 100;
$totalAmt = $this->Order->Cart->Totals->discount;
$price = $totalAmt - $totalAmt / $rate;
$discount = $totalAmt - $price;
$goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-cardpay'), 'title' => __('Discount', 'shopp-billmate-cardpay'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => (double) $taxrate * 100, 'discount' => (double) 0, 'flags' => $flag));
}
if (!empty($this->Order->Cart->Totals->shipping)) {
/* $taxrate = $taxrate * 100;
$rate = (100+$taxrate)/100;
$totalAmt = $this->Order->Cart->Totals->shipping;
$price = $totalAmt-($totalAmt/$rate);
$shipping = $totalAmt - $price;*/
$goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-cardpay'), 'title' => __('Shipping', 'shopp-billmate-cardpay'), 'price' => round($this->Order->Cart->Totals->shipping * 100, 0), 'vat' => (double) $taxrate * 100, 'discount' => 0, 'flags' => 8));
}
$pclass = -1;
$lang = explode("_", strtoupper(WPLANG));
$base = $Shopp->Settings->get('base_operations');
$_ = array();
$transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $base['currency']['code'], "country" => 209, "language" => $lang[0], "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $Customer->id, "creditcard_data" => $_POST)));
if (!empty($this->Order->capture) && $this->Order->capture == 'YES') {
$transaction["extraInfo"][0]["status"] = 'Paid';
}
if ($add_order) {
return $k->AddOrder($pno, $bill_address, $ship_address, $goods_list, $transaction);
}
if (!isset($_SESSION['card_invoice_called']) || $_SESSION['card_invoice_called'] == false) {
$result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
} else {
$result1[0] = $_SESSION['card_invoice_called_inv'];
}
if (!is_array($result1)) {
new ShoppError(__('Unable to process billmate try again <br/>Error:', 'shopp-billmate-cardpay') . utf8_encode($result1), 2);
echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'checkout') . '";</script>';
die;
} else {
$this->Order->billmateId = $result1[0];
}
}
示例13: parse_location
public static function parse_location($destination)
{
$selected = array('region' => '*', 'country' => '', 'area' => '', 'zone' => '');
$selection = array();
if (strpos($destination, ',') !== false) {
$selection = explode(',', $destination);
} else {
$selection = array($destination);
}
if (!is_array($selection)) {
$selection = array($selection);
}
$keys = array_slice(array_keys($selected), 0, count($selection));
$selected = array_merge($selected, array_combine($keys, $selection));
extract($selected);
foreach ($selected as $name => &$value) {
if ($value == '') {
continue;
}
switch ($name) {
case 'region':
if ('*' == $value) {
$value = __('Worldwide', 'Shopp');
} else {
$regions = Lookup::regions();
if (isset($regions[$value])) {
$value = $regions[$value];
}
}
break;
case 'country':
$countries = Lookup::countries();
$selected['countrycode'] = $value;
if (isset($countries[$value])) {
$value = $countries[$value]['name'];
}
break;
case 'zone':
$zones = Lookup::country_zones();
if (isset($zones[$country])) {
$zones = $zones[$country];
}
if (isset($zones[$value])) {
$value = $zones[$value];
}
break;
}
}
return $selected;
}
示例14: destination
/**
* Sets the shipping address location for calculating
* shipping estimates.
*
* @since 1.1
*
* @return void Description...
**/
function destination ($data=false) {
global $Ecart;
$base = $Ecart->Settings->get('base_operations');
$countries = Lookup::countries();
$regions = Lookup::regions();
if ($data) $this->updates($data);
// Update state if postcode changes for tax updates
if (isset($this->postcode))
$this->postarea();
if (empty($this->country))
$this->country = $base['country'];
$this->region = false;
if (isset($regions[$countries[$this->country]['region']]))
$this->region = $regions[$countries[$this->country]['region']];
}