echo '<br />' . CALLBACK_CONNECTION_ERROR; } } else { echo '<br />' . CALLBACK_CONNECTION_ERROR; } } else { echo '<br />' . CALLBACK_CONNECTION_ERROR; } } else { echo '<br />' . CALLBACK_ERROR_CONTACTS; } break; case 'show_all_countries_pull_down': $all_countries_array = array(); $all_countries_unsorted = array(); $all_countries = tep_get_shops_countries(); reset($all_countries); while (list($country_code, $country_info) = each($all_countries)) { if ($country_info['phone_code'] > 0) { $all_countries_unsorted[$country_code] = $languages_id == DEFAULT_LANGUAGE_ID ? $country_info['country_ru_name'] : $country_info['country_name']; } } reset($all_countries_unsorted); asort($all_countries_unsorted); while (list($country_code, $country_name) = each($all_countries_unsorted)) { $all_countries_array[] = array('id' => $country_code, 'text' => $country_name); } echo tep_draw_pull_down_menu('callback_country_code', $all_countries_array, tep_not_null($HTTP_GET_VARS['country_code']) ? $HTTP_GET_VARS['country_code'] : $session_country_code, 'style="width: 90px;" onchange="document.getElementById(\'callback_country\').innerHTML = \' <img src="' . DIR_WS_ICONS . 'flags/\'+this.options[this.selectedIndex].value.toLowerCase()+\'.gif" /> <input type="hidden" name="callback_country_code" value="\'+this.options[this.selectedIndex].value+\'" /> \'; if (document.getElementById(\'callback_change_country\')) document.getElementById(\'callback_change_country\').style.display = \'\'; else parent.document.getElementById(\'callback_change_country\').style.display = \'\';" onblur="document.getElementById(\'callback_country\').innerHTML = \' <img src="' . DIR_WS_ICONS . 'flags/\'+this.options[this.selectedIndex].value.toLowerCase()+\'.gif" /> <input type="hidden" name="callback_country_code" value="\'+this.options[this.selectedIndex].value+\'" /> \'; if (document.getElementById(\'callback_change_country\')) document.getElementById(\'callback_change_country\').style.display = \'\'; else parent.document.getElementById(\'callback_change_country\').style.display = \'\';"'); //; break; case 'test_block':
function tep_get_zone_code($country_id, $zone_id, $default_zone) { $return_zone = $default_zone; $all_countries = tep_get_shops_countries(); reset($all_countries); while (list(, $country_info) = each($all_countries)) { if ($country_info['country_id'] == $country_id) { tep_db_select_db($country_info['shops_db']); break; } } $zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int) $country_id . "' and zone_id = '" . (int) $zone_id . "'"); if (tep_db_num_rows($zone_query)) { $zone = tep_db_fetch_array($zone_query); $return_zone = $zone['zone_code']; } tep_db_select_db(DB_DATABASE); return $return_zone; }
function cart() { global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment; $this->content_type = $cart->get_content_type(); $shop_countries = tep_get_shops_countries(); $customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, ab.entry_country_id, ab.entry_telephone, ab.entry_state, c.customers_email_address, c.customers_telephone from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab where c.customers_id = '" . (int) $customer_id . "' and ab.customers_id = '" . (int) $customer_id . "' and c.customers_default_address_id = ab.address_book_id"); $customer_address = tep_db_fetch_array($customer_address_query); if (!is_array($customer_address)) { $customer_address = array(); } $country_info_query = tep_db_query("select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int) $customer_address['entry_country_id'] . "' and language_id = '" . (int) $languages_id . "'"); $country_info = tep_db_fetch_array($country_info_query); if (!is_array($country_info)) { $country_info = array(); reset($shop_countries); while (list(, $shop_country) = each($shop_countries)) { if ($shop_country['country_id'] == $customer_address['entry_country_id']) { $country_info = array('countries_id' => $shop_country['country_id'], 'countries_name' => $shop_country['country_name'], 'countries_iso_code_2' => $shop_country['country_code'], 'countries_iso_code_3' => $shop_country['country_code_3'], 'address_format_id' => $shop_country['address_format_id']); break; } } } $zone_info_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int) $customer_address['entry_zone_id'] . "'"); $zone_info = tep_db_fetch_array($zone_info_query); if (!is_array($zone_info)) { $zone_info = array(); } $customer_address = array_merge($customer_address, $country_info, $zone_info); $company = array(); $company_info_query = tep_db_query("select * from " . TABLE_COMPANIES . " where customers_id = '" . (int) $customer_id . "'"); $company_info = tep_db_fetch_array($company_info_query); if (!is_array($company_info)) { $company_info = array(); } reset($company_info); while (list($k, $v) = each($company_info)) { $k = str_replace('companies_', 'company_', $k); $k = str_replace('company_full_name', 'company_full', $k); $k = str_replace('company_name', 'company', $k); $company[$k] = $v; } $shipping_address_query = tep_db_query("select entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_zone_id, entry_country_id, entry_telephone, entry_state from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $sendto . "'"); $shipping_address = tep_db_fetch_array($shipping_address_query); if (!is_array($shipping_address)) { $shipping_address = array(); } $country_info_query = tep_db_query("select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int) $shipping_address['entry_country_id'] . "' and language_id = '" . (int) $languages_id . "'"); $country_info = tep_db_fetch_array($country_info_query); if (!is_array($country_info)) { $country_info = array(); reset($shop_countries); while (list(, $shop_country) = each($shop_countries)) { if ($shop_country['country_id'] == $shipping_address['entry_country_id']) { $country_info = array('countries_id' => $shop_country['country_id'], 'countries_name' => $shop_country['country_name'], 'countries_iso_code_2' => $shop_country['country_code'], 'countries_iso_code_3' => $shop_country['country_code_3'], 'address_format_id' => $shop_country['address_format_id']); break; } } } $zone_info_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int) $shipping_address['entry_zone_id'] . "'"); $zone_info = tep_db_fetch_array($zone_info_query); if (!is_array($zone_info)) { $zone_info = array(); } $shipping_address = array_merge($shipping_address, $country_info, $zone_info); $billing_address_query = tep_db_query("select entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_zone_id, entry_country_id, entry_telephone, entry_state from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $billto . "'"); $billing_address = tep_db_fetch_array($billing_address_query); if (!is_array($billing_address)) { $billing_address = array(); } $country_info_query = tep_db_query("select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int) $billing_address['entry_country_id'] . "' and language_id = '" . (int) $languages_id . "'"); $country_info = tep_db_fetch_array($country_info_query); if (!is_array($country_info)) { $country_info = array(); reset($shop_countries); while (list(, $shop_country) = each($shop_countries)) { if ($shop_country['country_id'] == $billing_address['entry_country_id']) { $country_info = array('countries_id' => $shop_country['country_id'], 'countries_name' => $shop_country['country_name'], 'countries_iso_code_2' => $shop_country['country_code'], 'countries_iso_code_3' => $shop_country['country_code_3'], 'address_format_id' => $shop_country['address_format_id']); break; } } } $zone_info_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int) $billing_address['entry_zone_id'] . "'"); $zone_info = tep_db_fetch_array($zone_info_query); if (!is_array($zone_info)) { $zone_info = array(); } $billing_address = array_merge($billing_address, $country_info, $zone_info); $tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int) $customer_id . "' and ab.address_book_id = '" . (int) ($this->content_type == 'virtual' ? $billto : $sendto) . "'"); $tax_address = tep_db_fetch_array($tax_address_query); $this->info = array('code' => '', 'order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $currency, 'currency_value' => $currencies->currencies[$currency]['value'], 'is_paid' => '0', 'payment_method' => $payment, 'cc_type' => isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : '', 'cc_owner' => isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : '', 'cc_number' => isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : '', 'cc_expires' => isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : '', 'check_account_type' => isset($GLOBALS['check_account_type']) ? $GLOBALS['check_account_type'] : '', 'check_bank_name' => isset($GLOBALS['check_bank_name']) ? $GLOBALS['check_bank_name'] : '', 'check_routing_number' => isset($GLOBALS['check_routing_number']) ? $GLOBALS['check_routing_number'] : '', 'check_account_number' => isset($GLOBALS['check_account_number']) ? $GLOBALS['check_account_number'] : '', 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'subtotal' => 0, 'tax' => 0, 'tax_groups' => array(), 'comments' => isset($GLOBALS['comments']) ? $GLOBALS['comments'] : '', 'delivery_transfer' => $cart->info['delivery_transfer'], 'shops_id' => SHOP_ID); if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) { $this->info['payment_method'] = $GLOBALS[$payment]->title; if (isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && $GLOBALS[$payment]->order_status > 0) { $this->info['order_status'] = $GLOBALS[$payment]->order_status; } } $this->customer = array('id' => $customer_id, 'firstname' => $customer_address['customers_firstname'], 'lastname' => $customer_address['customers_lastname'], 'street_address' => $customer_address['entry_street_address'], 'suburb' => $customer_address['entry_suburb'], 'city' => $customer_address['entry_city'], 'postcode' => $customer_address['entry_postcode'], 'state' => tep_not_null($customer_address['entry_state']) ? $customer_address['entry_state'] : $customer_address['zone_name'], 'zone_id' => $customer_address['entry_zone_id'], 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['entry_telephone'], 'email_address' => $customer_address['customers_email_address']); $this->customer = array_merge($this->customer, $company); $this->delivery = array('firstname' => $shipping_address['entry_firstname'], 'lastname' => $shipping_address['entry_lastname'], 'street_address' => $shipping_address['entry_street_address'], 'suburb' => $shipping_address['entry_suburb'], 'city' => $shipping_address['entry_city'], 'postcode' => $shipping_address['entry_postcode'], 'state' => tep_not_null($shipping_address['entry_state']) ? $shipping_address['entry_state'] : $shipping_address['zone_name'], 'zone_id' => $shipping_address['entry_zone_id'], 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), 'country_id' => $shipping_address['entry_country_id'], 'telephone' => $shipping_address['entry_telephone'], 'format_id' => $shipping_address['address_format_id']); $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], 'street_address' => $billing_address['entry_street_address'], 'suburb' => $billing_address['entry_suburb'], 'city' => $billing_address['entry_city'], 'postcode' => $billing_address['entry_postcode'], 'state' => tep_not_null($billing_address['entry_state']) ? $billing_address['entry_state'] : $billing_address['zone_name'], 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'telephone' => $billing_address['entry_telephone'], 'format_id' => $billing_address['address_format_id']); $index = 0; $products = $cart->get_products(); for ($i = 0, $n = sizeof($products); $i < $n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'code' => $products[$i]['code'], 'manufacturer' => $products[$i]['manufacturer'], 'year' => $products[$i]['year'], 'type' => $products[$i]['type'], 'periodicity' => $products[$i]['periodicity'], 'periodicity_min' => $products[$i]['periodicity_min'], 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'weight' => $products[$i]['weight'], 'warranty' => $products[$i]['warranty'], 'id' => $products[$i]['id']); if (tep_not_null($products[$i]['filename'])) { $this->products[$index]['filename'] = $products[$i]['filename']; $this->products[$index]['download_maxdays'] = DOWNLOAD_MAX_DAYS; $this->products[$index]['download_count'] = DOWNLOAD_MAX_COUNT; } $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price; $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['tax'] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); if (isset($this->info['tax_groups']["{$products_tax_description}"])) { $this->info['tax_groups']["{$products_tax_description}"] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); } else { $this->info['tax_groups']["{$products_tax_description}"] = $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); } } else { $this->info['tax'] += $products_tax / 100 * $shown_price; if (isset($this->info['tax_groups']["{$products_tax_description}"])) { $this->info['tax_groups']["{$products_tax_description}"] += $products_tax / 100 * $shown_price; } else { $this->info['tax_groups']["{$products_tax_description}"] = $products_tax / 100 * $shown_price; } } $index++; } if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } }
function tep_get_boards_countries() { $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT)); $countries = tep_get_shops_countries(0, 1); reset($countries); while (list(, $country_info) = each($countries)) { $countries_array[] = array('id' => $country_info['country_ru_name'], 'text' => $country_info['country_ru_name']); } return $countries_array; }