Exemplo n.º 1
0
    /**
     * @inheritdoc
     */
    public function xml()
    {
        $template = $this->product->getTemplate();
        $company = $this->getCompany($template->company_id);
        $location = fn_get_country_name($company['company_country']);
        $secondary_category = $this->product->getExternalSecondCategoryId();
        $secondary_category_xml = "";
        if (!empty($secondary_category)) {
            $secondary_category_xml = <<<XML
            <SecondaryCategory>
                <CategoryID>{$secondary_category}</CategoryID>
            </SecondaryCategory>
XML;
        }
        return <<<XML
        <Item>
            {$this->getItemIdXml()}
            <Site>{$template->site}</Site>
            <ListingType>FixedPriceItem</ListingType>
            <Currency>{$this->getCurrency()}</Currency>
            <PrimaryCategory>
                <CategoryID>{$this->product->getExternalCategoryId()}</CategoryID>
            </PrimaryCategory>
            {$secondary_category_xml}
            <ConditionID>{$template->condition_id}</ConditionID>
            <CategoryMappingAllowed>true</CategoryMappingAllowed>
            <Country>{$company['company_country']}</Country>
            <PostalCode>{$company['company_zipcode']}</PostalCode>
            <Location><![CDATA[{$location}]]></Location>
            <Title><![CDATA[{$this->product->title}]]></Title>
            <Description><![CDATA[{$this->product->description}]]></Description>
            <ListingDuration><![CDATA[{$template->ebay_duration}]]></ListingDuration>
            <DispatchTimeMax><![CDATA[{$template->dispatch_days}]]></DispatchTimeMax>
            <ReturnPolicy>
                <ReturnsAcceptedOption><![CDATA[{$template->return_policy}]]></ReturnsAcceptedOption>
                <RefundOption><![CDATA[{$template->refund_method}]]></RefundOption>
                <ReturnsWithinOption><![CDATA[{$template->contact_time}]]></ReturnsWithinOption>
                <Description><![CDATA[{$template->return_policy_descr}]]></Description>
                <ShippingCostPaidByOption><![CDATA[{$template->cost_paid_by}]]></ShippingCostPaidByOption>
            </ReturnPolicy>
            {$this->getPaymentXml()}
            {$this->getShippingXml()}
            {$this->getPictureDetailsXml()}
            {$this->getFeaturesXml()}
            {$this->getProductOptionsXml()}
            {$this->getAdditionalXml()}
        </Item>
XML;
    }
Exemplo n.º 2
0
 $sboraddr_id = $address[0];
 $sboraddr_owner_id = $address[1];
 $addr_list = RusSpsr::WAGetAddrList(8);
 foreach ($addr_list as $addr) {
     if ($addr['SborAddr_ID'] == $sboraddr_id && $addr['SborAddr_Owner_ID'] == $sboraddr_owner_id) {
         $sipper_data = $addr;
     }
 }
 if (empty($sipper_data)) {
     return array(CONTROLLER_STATUS_REDIRECT, "spsr_addr.manage");
 }
 $_sipper_data = RusSpsr::WAGetCities(array('city' => $sipper_data['CityName1']));
 $shipper_for_xml = array('PostCode' => $sipper_data['PostCode'], 'Region' => $_sipper_data['RegionName'], 'City' => $sipper_data['CityName1'], 'Address' => $sipper_data['Address'], 'CompanyName' => $sipper_data['Organization'], 'ContactName' => $sipper_data['FIO'], 'Phone' => $sipper_data['Phone']);
 $shipper_xml = RusSpsr::arraySimpleXml('Shipper', $shipper_for_xml);
 $city_data = RusSpsr::WAGetCities(array('city' => $order_info['s_city'], 'country' => $order_info['s_country']));
 $country_name = fn_get_country_name($order_info['s_country'], 'ru');
 foreach ($invoices as $invoice_key => $invoice) {
     if (isset($spsr_invoice['barcodes'][$invoice_key]) && !empty($spsr_invoice['barcodes'][$invoice_key])) {
         $total_weight += $invoice['weight'];
         $shipment_id = $invoice['shipment']['shipment_id'];
         $service_params = $invoice['service_params'];
         $additional_params = $service_params['service_params'];
         $settings_shipping_spsr = $params['settings_shipping_spsr'][$invoice_key];
         $receiver_for_xml = array('PostCode' => $order_info['s_zipcode'], 'Country' => $country_name, 'Region' => $city_data['RegionName'], 'City' => $city_data['CityName'], 'Address' => $order_info['s_address'], 'CompanyName' => $order_info['company'], 'ContactName' => $order_info['s_firstname'] . ' ' . $order_info['s_lastname'], 'Phone' => $order_info['s_phone'], 'Comment' => $invoice['shipment']['comments'], 'Email' => $order_info['email'], 'ConsigneeCollect' => $settings_shipping_spsr['to_be_called_for']);
         $receiver_xml = RusSpsr::arraySimpleXml('Receiver', $receiver_for_xml);
         $additional_services_for_xml = array('COD' => $settings_shipping_spsr['cod'], 'PartDelivery' => $additional_params['part_delivery'], 'CheckContents' => $additional_params['check_contents'], 'Verify' => $additional_params['verify'], 'ReturnDoc' => $settings_shipping_spsr['return_doc'], 'TryOn' => $settings_shipping_spsr['try_on'], 'ByHand' => $settings_shipping_spsr['by_hand'], 'PaidByReceiver' => $additional_params['paid_by_receiver'], 'AgreedDelivery' => $settings_shipping_spsr['agreed_delivery'], 'IDC' => $settings_shipping_spsr['idc']);
         $additional_services_xml = RusSpsr::arraySimpleXml('AdditionalServices', $additional_services_for_xml);
         if ($settings_shipping_spsr['sms_to_shipper'] == 1 && !empty($sipper_data['Phone'])) {
             $sms_for_xml['SMStoShipper'] = $settings_shipping_spsr['sms_to_shipper'];
             $sms_for_xml['SMSNumberShipper'] = trim($sipper_data['Phone']);
         }
Exemplo n.º 3
0
function fn_get_gift_certificate_info($certificate, $type = 'B', $stored_products = array(), $lang_code = CART_LANGUAGE)
{
    if ($type == 'B' && is_numeric($certificate)) {
        $_certificate = db_get_row("SELECT * FROM ?:gift_certificates WHERE gift_cert_id = ?i", $certificate);
    } elseif ($type == 'C' && is_numeric($certificate)) {
        $_certificate = fn_array_merge($_SESSION['cart']['gift_certificates'][$certificate], array('gift_cert_cart_id' => $certificate));
    } elseif ($type == 'P' && is_array($certificate)) {
        $_certificate = $certificate;
        if (empty($_certificate['gift_cert_code'])) {
            $_certificate['gift_cert_code'] = preg_replace('/[0-9A-Z]/', 'X', fn_generate_gift_certificate_code());
        }
    }
    fn_set_hook('get_gift_certificate_info', $_certificate, $certificate, $type);
    if (!empty($_certificate)) {
        //Prepare descriptions
        if (!empty($_certificate['state'])) {
            $_descr_state = fn_get_state_name($_certificate['state'], $_certificate['country'], $lang_code);
            $_certificate['descr_state'] = empty($_descr_state) ? $_certificate['state'] : $_descr_state;
        }
        if (!empty($_certificate['country'])) {
            $_certificate['descr_country'] = fn_get_country_name($_certificate['country'], $lang_code);
        }
        if (!empty($_certificate['products'])) {
            if ($type == 'B') {
                $_certificate['products'] = @unserialize($_certificate['products']);
            }
            fn_fill_certificate_products($_certificate['products'], $stored_products, $lang_code);
        }
        if (!empty($_certificate['debit_products'])) {
            if ($type == 'B') {
                $_certificate['debit_products'] = @unserialize($_certificate['debit_products']);
            }
            fn_fill_certificate_products($_certificate['debit_products'], $stored_products, $lang_code);
        }
    }
    return $_certificate;
}
Exemplo n.º 4
0
    private function _getBaseItemData($product, $template, $images_data)
    {
        $currency = CART_PRIMARY_CURRENCY;
        $shippings = $this->prepareShipping($product, $template);
        $company = fn_get_company_placement_info(Registry::get('runtime.company_id'));
        $price = fn_format_price($product['price']);
        $picture_details = '';
        if ($product['override'] == "Y") {
            $title = substr(strip_tags($product['ebay_title']), 0, 80);
            $description = !empty($product['ebay_description']) ? $product['ebay_description'] : $product['full_description'];
        } else {
            $title = substr(strip_tags($product['product']), 0, 80);
            $description = $product['full_description'];
        }
        $payments = '<PaymentMethods>' . implode("</PaymentMethods>\n<PaymentMethods>", $template['payment_methods']) . '</PaymentMethods>';
        if (in_array('PayPal', $template['payment_methods'])) {
            $payments .= "\n<PayPalEmailAddress>{$template['paypal_email']}</PayPalEmailAddress>";
        }
        if (!empty($product['main_pair']) && !empty($product['main_pair']['detailed']) && !empty($product['main_pair']['detailed']['http_image_path']) && $images_data[md5($product['main_pair']['detailed']['http_image_path'])]) {
            $image_url = $images_data[md5($product['main_pair']['detailed']['http_image_path'])];
            $picture_details .= "<PictureURL>{$image_url}</PictureURL>\n";
        }
        if ($product['image_pairs']) {
            foreach ($product['image_pairs'] as $image_pair) {
                if (!empty($images_data[md5($image_pair['detailed']['http_image_path'])])) {
                    $image_url = $images_data[md5($image_pair['detailed']['http_image_path'])];
                    $picture_details .= "<PictureURL>{$image_url}</PictureURL>\n";
                }
            }
        }
        $picture_details = empty($picture_details) ? '' : "<PictureDetails>\n{$picture_details}</PictureDetails>";
        $product_features = '';
        if (!empty($product['product_features'])) {
            $product_features = '<ItemSpecifics>' . fn_prepare_xml_product_features($product['product_features']) . '</ItemSpecifics>';
        }
        $product_options = '';
        $start_price = '';
        $product_quantity = '';
        $inventory_combinations = db_get_array("SELECT combination FROM ?:product_options_inventory WHERE product_id = ?i AND amount > 0 AND combination != ''", $product['product_id']);
        if (!empty($product['product_options']) && !empty($inventory_combinations)) {
            $params = array('page' => 1, 'product_id' => $product['product_id']);
            $product_options = '<Variations>' . fn_prepare_xml_product_options($params, $product, $images_data) . '</Variations>';
        }
        if (empty($product_options)) {
            $start_price = '<StartPrice currencyID="' . $currency . '">' . $price . '</StartPrice>';
            $product_quantity = '<Quantity>' . $product['amount'] . '</Quantity>';
        }
        $location = fn_get_country_name($company['company_country']);
        $xml = <<<EOT
<ItemID>{$product['ebay_item_id']}</ItemID>
<Site>{$template['site']}</Site>
<ListingType>FixedPriceItem</ListingType>
<Currency>{$currency}</Currency>
<PrimaryCategory>
<CategoryID>{$template['category']}</CategoryID>
</PrimaryCategory>
<SecondaryCategory>
<CategoryID>{$template['sec_category']}</CategoryID>
</SecondaryCategory>
<ConditionID>{$template['condition_id']}</ConditionID>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<Country>{$company['company_country']}</Country>
<PostalCode>{$company['company_zipcode']}</PostalCode>
<Location>{$location}</Location>
<Title><![CDATA[{$title}]]></Title>
<Description><![CDATA[{$description}]]></Description>
{$payments}
<ListingDuration>{$template['ebay_duration']}</ListingDuration>
<DispatchTimeMax>{$template['dispatch_days']}</DispatchTimeMax>
{$shippings}
{$picture_details}
{$product_features}
{$product_options}
{$start_price}
{$product_quantity}
EOT;
        return $xml;
    }
Exemplo n.º 5
0
/**
 * Function returns address of company and emails of company' departments.
 *
 * @param integer $company_id ID of company
 * @param string $lang_code Language of retrieving data. If null, lang_code of company will be used.
 * @return array Company address, emails and lang_code.
 */
function fn_get_company_placement_info($company_id, $lang_code = null)
{
    $default_company_placement_info = Registry::get('settings.Company');
    if (empty($company_id)) {
        $company_placement_info = $default_company_placement_info;
        $company_placement_info['lang_code'] = !empty($lang_code) ? $lang_code : CART_LANGUAGE;
    } else {
        $company = fn_get_company_data($company_id, !empty($lang_code) ? $lang_code : CART_LANGUAGE);
        if (fn_allowed_for('ULTIMATE')) {
            $company_placement_info = Settings::instance()->getValues('Company', Settings::CORE_SECTION, true, $company_id);
            $default_company_placement_info = $company_placement_info;
            $company_placement_info['lang_code'] = $company['lang_code'];
        } else {
            $company_placement_info = array('company_name' => $company['company'], 'company_address' => $company['address'], 'company_city' => $company['city'], 'company_country' => $company['country'], 'company_state' => $company['state'], 'company_zipcode' => $company['zipcode'], 'company_phone' => $company['phone'], 'company_phone_2' => '', 'company_fax' => $company['fax'], 'company_website' => $company['url'], 'company_users_department' => $company['email'], 'company_site_administrator' => $company['email'], 'company_orders_department' => $company['email'], 'company_support_department' => $company['email'], 'company_newsletter_email' => $company['email'], 'lang_code' => $company['lang_code']);
        }
    }
    foreach ($default_company_placement_info as $k => $v) {
        $company_placement_info['default_' . $k] = $v;
    }
    $lang_code = !empty($lang_code) ? $lang_code : $company_placement_info['lang_code'];
    $company_placement_info['company_country_descr'] = fn_get_country_name($company_placement_info['company_country'], $lang_code);
    $company_placement_info['company_state_descr'] = fn_get_state_name($company_placement_info['company_state'], $company_placement_info['company_country'], $lang_code);
    return $company_placement_info;
}
Exemplo n.º 6
0
    public static function WAGetCities($location)
    {
        $city_name = $location['city'];
        $url = self::$url;
        if (!empty($location['country'])) {
            $country_name = fn_get_country_name($location['country'], 'ru');
        } else {
            $country_name = '';
        }
        $data = <<<EOT
        <root xmlns="http://spsr.ru/webapi/Info/GetCities/1.0">
            <p:Params Name="WAGetCities" Ver="1.0" xmlns:p="http://spsr.ru/webapi/WA/1.0" />
            <GetCities CityName="{$city_name}" CountryName="{$country_name}"/>
        </root>
EOT;
        $response = Http::post($url, $data, self::$extra);
        $xml = simplexml_load_string($response);
        $return = false;
        $status_code = (string) $xml->Result['RC'];
        if ($status_code != 0) {
            self::$last_error = !empty(self::$_error_descriptions[$status_code]) ? self::$_error_descriptions[$status_code] : __("shippings.spsr.error_city");
        } else {
            if (isset($xml->City->Cities) && !empty($xml->City)) {
                $return = array();
                $city_name = fn_strtolower($city_name);
                foreach ($xml->City->Cities as $city) {
                    $spsr_city = fn_strtolower((string) $city['CityName']);
                    if ($spsr_city == $city_name) {
                        $return = self::attributesToArray($city);
                    }
                }
            }
        }
        if (empty($return)) {
            self::$last_error = __("shipping.sdek.not_city");
        }
        return $return;
    }
Exemplo n.º 7
0
function fn_add_user_data_descriptions(&$user_data, $lang_code = CART_LANGUAGE)
{
    fn_fill_user_fields($user_data);
    // Replace country and state values with their descriptions
    if (!empty($user_data['b_country'])) {
        $user_data['b_country_descr'] = fn_get_country_name($user_data['b_country'], $lang_code);
    }
    if (!empty($user_data['s_country'])) {
        $user_data['s_country_descr'] = fn_get_country_name($user_data['s_country'], $lang_code);
    }
    if (!empty($user_data['b_state'])) {
        $user_data['b_state_descr'] = fn_get_state_name($user_data['b_state'], $user_data['b_country'], $lang_code);
        if (empty($user_data['b_state_descr'])) {
            $user_data['b_state_descr'] = $user_data['b_state'];
        }
    }
    if (!empty($user_data['s_state'])) {
        $user_data['s_state_descr'] = fn_get_state_name($user_data['s_state'], $user_data['s_country'], $lang_code);
        if (empty($user_data['s_state_descr'])) {
            $user_data['s_state_descr'] = $user_data['s_state'];
        }
    }
}
Exemplo n.º 8
0
        $lastname = $order_info['lastname'];
    } elseif (!empty($order_info['b_lastname'])) {
        $lastname = $order_info['b_lastname'];
    } elseif (!empty($order_info['s_lastname'])) {
        $lastname = $order_info['s_lastname'];
    }
    if (!empty($order_info['firstname'])) {
        $firstname = $order_info['firstname'];
    } elseif (!empty($order_info['b_firstname'])) {
        $firstname = $order_info['b_firstname'];
    } elseif (!empty($order_info['s_firstname'])) {
        $firstname = $order_info['s_firstname'];
    }
    $order_info['fio'] = $lastname . ' ' . $firstname;
    $order_info['state_name'] = fn_get_state_name($order_info['s_state'], $order_info['s_country'], DESCR_SL);
    $order_info['country_name'] = fn_get_country_name($order_info['s_country'], DESCR_SL);
    $order_info['address_line_2'] = $order_info['country_name'] . ', ' . $order_info['state_name'] . ', ' . $order_info['s_city'];
    if (!empty($order_info['phone'])) {
        $order_info['recipient_phone'] = fn_rus_russianpost_normalize_phone($order_info['phone']);
    } elseif (!empty($order_info['b_phone'])) {
        $order_info['recipient_phone'] = fn_rus_russianpost_normalize_phone($order_info['b_phone']);
    } elseif (!empty($order_info['s_phone'])) {
        $order_info['recipient_phone'] = fn_rus_russianpost_normalize_phone($order_info['s_phone']);
    }
    Tygh::$app['view']->assign('pre_total', $total);
    Tygh::$app['view']->assign('order_info', $order_info);
    $pre_data = Registry::get('addons.rus_russianpost');
    $pre_data['company_phone'] = fn_rus_russianpost_normalize_phone($pre_data['company_phone']);
    Tygh::$app['view']->assign('pre_data', $pre_data);
}
function fn_rus_russianpost_normalize_phone($data_phone)
Exemplo n.º 9
0
 /**
  * Prepare request information
  *
  * @return array Prepared data
  */
 public function getRequestData()
 {
     $data_url = array('headers' => array('Content-Type: application/json'), 'timeout' => $this->_timeout);
     $weight_data = fn_expand_weight($this->_shipping_info['package_info']['W']);
     $shipping_settings = $this->_shipping_info['service_params'];
     $origination = $this->_shipping_info['package_info']['origination'];
     $location = $this->_shipping_info['package_info']['location'];
     $origin['country'] = fn_get_country_name($origination['country'], 'ru');
     $origin['region'] = fn_get_state_name($origination['state'], $origination['country'], 'RU');
     $origin['city'] = $origination['city'];
     $destination['country'] = fn_get_country_name($location['country'], 'ru');
     $destination['region'] = fn_get_state_name($location['state'], $location['country'], 'RU');
     $destination['city'] = $location['city'];
     $international = false;
     if ($origination['country'] != 'RU' || $location['country'] != 'RU') {
         $international = true;
     }
     $country_code = db_get_field("SELECT code_N3 FROM ?:countries WHERE code = ?s", $location['country']);
     if (empty($location['zipcode'])) {
         $this->_internalError(__('russian_post_empty_zipcode'));
         $location['zipcode'] = false;
     }
     $ruble = Registry::get('currencies.RUB');
     if (empty($ruble) || $ruble['is_primary'] == 'N') {
         $this->_internalError(__('russian_post_activation_error'));
     }
     $weight = $weight_data['plain'] * Registry::get('settings.General.weight_symbol_grams');
     $total_cost = $this->_shipping_info['package_info']['C'];
     if (CART_PRIMARY_CURRENCY != 'RUB') {
         $total_cost = fn_rus_russianpost_format_price($total_cost, 'RUB');
     }
     $insurance = $shipping_settings['insurance'];
     $cash_sum = 0;
     if (!empty($shipping_settings['cash_on_delivery'])) {
         $cash_sum = $total_cost * $shipping_settings['cash_on_delivery'] / 100;
     }
     $insurance_sum = 0;
     if (!empty($insurance) || !empty($cash_sum)) {
         if ($total_cost > $cash_sum) {
             $insurance_sum = $total_cost;
         } else {
             $insurance_sum = $cash_sum;
         }
     }
     $is_wayforward = false;
     if ($shipping_settings['shipping_option'] != 'AVIA') {
         $is_wayforward = true;
     }
     $mailing = array('postingType' => 'VPO', 'postingCategory' => 'SIMPLE', 'weight' => $weight, 'zipCodeFrom' => $origination['zipcode'], 'zipCodeTo' => $location['zipcode'], 'postingKind' => 'POST_CARD');
     if ($international) {
         $mailing['postingType'] = 'MPO';
     }
     if ($shipping_settings['delivery_notice']) {
         $mailing['notificationOfDeliveryRpo'] = $shipping_settings['delivery_notice'];
     }
     if ($shipping_settings['inventory']) {
         $mailing['inventory'] = true;
     }
     if ($shipping_settings['careful']) {
         $mailing['careful'] = true;
     }
     $main_type = 'banderol';
     if ($shipping_settings['shipping_option'] == 'EMS') {
         $main_type = 'ems';
     } elseif ($shipping_settings['sending_type'] != 'papers' || $weight > 2000) {
         if ($weight < 10000) {
             $main_type = 'standardParcel';
         } elseif ($weight >= 10000 && $weight < 20000) {
             $main_type = 'heavyParcel';
         } elseif ($weight >= 20000) {
             $main_type = 'bigHeavyParcel';
         }
     }
     if ($main_type == 'banderol') {
         $mailing['postingKind'] = "BANDEROLE";
         $mailing['postingCategory'] = "ORDERED";
         $mailing['wayForward'] = "EARTH";
     } elseif ($main_type == 'standardParcel' || $main_type == 'heavyParcel' || $main_type == 'bigHeavyParcel') {
         $mailing['postingKind'] = "PARCEL";
         $mailing['postingCategory'] = "ORDINARY";
         $mailing['wayForward'] = "EARTH";
         if (!$is_wayforward) {
             $mailing['wayForward'] = "AVIA";
         }
         if ($main_type == 'standardParcel') {
             $mailing['parcelKind'] = "STANDARD";
         }
         if ($main_type == 'heavyParcel') {
             $mailing['parcelKind'] = "HEAVY";
         }
         if ($main_type == 'bigHeavyParcel') {
             $mailing['parcelKind'] = "HEAVY_LARGE_SIZED";
         }
     } elseif ($main_type == 'ems') {
         $mailing['postingKind'] = "EMS";
         $mailing['postingCategory'] = "ORDINARY";
     }
     $sending_type = "LETTER_PARCEL";
     if ($weight > 2000 && $shipping_settings['sending_type'] != 'papers') {
         $sending_type = "PACKAGE";
     }
     $product_state = array('fromCity' => $origin['city'], 'fromCountry' => $origin['country'], 'fromRegion' => $destination['region'], 'insuranceSum' => $insurance_sum, 'mainType' => $main_type, 'toCity' => $destination['city'], 'toCountry' => $destination['country'], 'toCountryCode' => $country_code, 'toRegion' => $destination['region'], 'weight' => $weight);
     $data_post = array('calculationEntity' => array('origin' => $origin, 'destination' => $destination, 'sendingType' => $sending_type), 'costCalculationEntity' => $mailing, 'productPageState' => $product_state);
     $url = "https://www.pochta.ru/calculator/v1/api/delivery.time.cost.get";
     //$url = "https://www.pochta.ru/portal-portlet/delegate/calculator/v1/api/delivery.time.cost.get";
     $request_data = array('method' => 'post', 'url' => $url, 'data' => json_encode($data_post), 'data_url' => $data_url);
     return $request_data;
 }
Exemplo n.º 10
0
function rus_spsr_get_cities($location)
{
    $city_name = $location['city'];
    $url = 'http://api.spsr.ru/waExec/WAExec';
    $extra = array('headers' => array('Content-Type: application/xml'));
    if (!empty($location['country'])) {
        $country_name = fn_get_country_name($location['country'], 'ru');
    } else {
        $country_name = '';
    }
    $data = <<<EOT
<root xmlns="http://spsr.ru/webapi/Info/GetCities/1.0">
<p:Params Name="WAGetCities" Ver="1.0" xmlns:p="http://spsr.ru/webapi/WA/1.0" />
<GetCities CityName="{$city_name}" CountryName="{$country_name}"/>
</root>
EOT;
    $response = Http::post($url, $data, $extra);
    $xml = @simplexml_load_string($response);
    $status_code = (string) $xml->Result['RC'];
    if ($status_code != 0) {
        return false;
    } else {
        if (isset($xml->City->Cities) && !empty($xml->City)) {
            $result = array();
            foreach ($xml->City->Cities as $key => $city) {
                $city_data = array();
                foreach ($city->attributes() as $a_key => $value) {
                    $city_data[$a_key] = (string) $value;
                }
                $result[] = $city_data;
            }
        }
    }
    if (empty($result)) {
        return false;
    }
    return $result;
}
Exemplo n.º 11
0
// init revisions
if (AREA == 'A' && Registry::get('settings.General.active_revisions_objects')) {
    require DIR_CORE . 'fn.revisions.php';
    fn_init_revisions();
}
// select the skin to display
fn_init_skin($_REQUEST);
// initialize templater
fn_init_templater();
// Second-level (b) cache: different for dispatch-language-currency
define('CACHE_LEVEL_DISPATCH', AREA . '_' . $_SERVER['REQUEST_METHOD'] . '_' . str_replace('.', '_', $_REQUEST['dispatch']) . '_' . (defined('CART_LOCALIZATION') ? CART_LOCALIZATION . '_' : '') . CART_LANGUAGE . '_' . CART_SECONDARY_CURRENCY);
Registry::register_cache('lang_cache', array('language_values'), CACHE_LEVEL_DISPATCH, true);
if (!defined('NO_SESSION')) {
    // Get descriptions for company country and state
    if (Registry::get('settings.Company.company_country')) {
        Registry::set('settings.Company.company_country_descr', fn_get_country_name(Registry::get('settings.Company.company_country')));
    }
    if (Registry::get('settings.Company.company_state')) {
        Registry::set('settings.Company.company_state_descr', fn_get_state_name(Registry::get('settings.Company.company_state'), Registry::get('settings.Company.company_country')));
    }
    // Unset notification message by its id
    if (!empty($_REQUEST['close_notification'])) {
        unset($_SESSION['notifications'][$_REQUEST['close_notification']]);
        exit;
    }
}
// Include user information
fn_init_user();
// Third-level (a) cache: different for dispatch-user-language-currency
define('CACHE_LEVEL_USER', AREA . '_' . $_SERVER['REQUEST_METHOD'] . '_' . str_replace('.', '_', $_REQUEST['dispatch']) . '.' . (!empty($_SESSION['auth']['usergroup_ids']) ? implode('_', $_SESSION['auth']['usergroup_ids']) : '') . '.' . (defined('CART_LOCALIZATION') ? CART_LOCALIZATION . '_' : '') . CART_LANGUAGE . '.' . CART_SECONDARY_CURRENCY);
// Third-level (b) cache: different for user(logged in/not)-usergroup-language-currency
Exemplo n.º 12
0
function fn_add_user_data_descriptions(&$user_data, $lang_code = CART_LANGUAGE)
{
    fn_fill_user_fields($user_data);
    // Replace titles ids with their descriptions
    $_titles = fn_get_static_data_section('T', false);
    $titles = array();
    foreach ($_titles as $val) {
        $titles[$val['param']] = $val;
    }
    if (!empty($user_data['title'])) {
        $user_data['title_descr'] = !empty($titles[$user_data['title']]['descr']) ? $titles[$user_data['title']]['descr'] : $user_data['title'];
    }
    if (!empty($user_data['b_title'])) {
        $user_data['b_title_descr'] = !empty($titles[$user_data['b_title']]['descr']) ? $titles[$user_data['b_title']]['descr'] : $user_data['b_title'];
    }
    if (!empty($user_data['s_title'])) {
        $user_data['s_title_descr'] = !empty($titles[$user_data['s_title']]['descr']) ? $titles[$user_data['s_title']]['descr'] : $user_data['s_title'];
    }
    // Replace country and state values with their descriptions
    if (!empty($user_data['b_country'])) {
        $user_data['b_country_descr'] = fn_get_country_name($user_data['b_country'], $lang_code);
    }
    if (!empty($user_data['s_country'])) {
        $user_data['s_country_descr'] = fn_get_country_name($user_data['s_country'], $lang_code);
    }
    if (!empty($user_data['b_state'])) {
        $user_data['b_state_descr'] = fn_get_state_name($user_data['b_state'], $user_data['b_country'], $lang_code);
        if (empty($user_data['b_state_descr'])) {
            $user_data['b_state_descr'] = $user_data['b_state'];
        }
    }
    if (!empty($user_data['s_state'])) {
        $user_data['s_state_descr'] = fn_get_state_name($user_data['s_state'], $user_data['s_country'], $lang_code);
        if (empty($user_data['s_state_descr'])) {
            $user_data['s_state_descr'] = $user_data['s_state'];
        }
    }
}
Exemplo n.º 13
0
 public static function getAddressByType($profile_fields, $type, $lang_code = CART_LANGUAGE)
 {
     $prefix = self::getAddressPrefixByType($type);
     $address = array();
     foreach ($profile_fields as $k => $v) {
         if (preg_match('/^' . $prefix . '([a-z]+)$/', $k, $matches)) {
             $address[$matches[1]] = $v;
         }
     }
     if (!empty($address['country'])) {
         $address['country_description'] = fn_get_country_name($address['country'], $lang_code);
         $address['states_count'] = self::getStatesCount($address['country']);
         if (!empty($address['state'])) {
             $address['state_description'] = fn_get_state_name($address['state'], $address['country'], $lang_code);
         }
     }
     return $address;
 }