Esempio n. 1
0
if (is_array($cart['products']) and $count_products) {
    // load customer country
    // use for filtering the available payment on the customer country
    $address = $cart['user'];
    if (isset($this->post['country']) && !empty($this->post['country']) && $this->post['country'] != $address['country']) {
        $address['country'] = $this->post['country'];
    }
    if (!$address['country']) {
        $user_country = 0;
    } else {
        $iso_customer = mslib_fe::getCountryByName($address['country']);
        $user_country = $iso_customer['cn_iso_nr'];
    }
    $delivery_user_country = $user_country;
    if (isset($this->post['different_delivery_address']) && $this->post['different_delivery_address'] > 0 && !empty($this->post['delivery_country'])) {
        $iso_customer = mslib_fe::getCountryByName($this->post['delivery_country']);
        $delivery_user_country = $iso_customer['cn_iso_nr'];
    }
    $payment_methods_product = array();
    $shipping_methods_product = array();
    $payment_methods_group = array();
    $shipping_methods_group = array();
    $payment_methods_user = array();
    $shipping_methods_user = array();
    $payment_methods = array();
    $shipping_methods = array();
    $load_mappings_order = array();
    $load_mappings_order[] = 'products';
    $load_mappings_order[] = 'customers_groups';
    $load_mappings_order[] = 'customers';
    foreach ($load_mappings_order as $mapping) {
Esempio n. 2
0
// hook
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/ajax_pages/get_method_costs.php']['getMethodCostsPreProc'])) {
    $params = array('cart' => &$cart);
    foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/ajax_pages/get_method_costs.php']['getMethodCostsPreProc'] as $funcRef) {
        \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
    }
}
// hook oef
$tmp_countries = mslib_fe::getCountryByName($this->post['d_cc']);
$mslib_cart->setCountry($this->post['b_cc'], $tmp_countries['cn_iso_nr']);
$mslib_cart->setShippingMethod($this->post['tx_multishop_pi1']['sid']);
$mslib_cart->setPaymentMethod($this->post['tx_multishop_pi1']['pid']);
$cart = $mslib_cart->getCart();
// disable tax if the country is different and vat id is valid (NL & BE only)
if (isset($this->post['b_cc']) && !empty($this->post['b_cc']) && $this->post['tx_multishop_vat_id']) {
    $iso_customer = mslib_fe::getCountryByName($this->post['b_cc']);
    $iso_customer['country'] = $iso_customer['cn_short_en'];
    $vat_id = $this->post['tx_multishop_vat_id'];
}
$this->ms['MODULES']['DISABLE_VAT_RATE'] = 0;
if ($this->ms['MODULES']['DISABLE_VAT_FOR_FOREIGN_CUSTOMERS_WITH_COMPANY_VAT_ID'] and $vat_id) {
    if (strtolower($iso_customer['country']) != strtolower($this->tta_shop_info['country'])) {
        $this->ms['MODULES']['DISABLE_VAT_RATE'] = 1;
    }
}
$countries_id = $tmp_countries['cn_iso_nr'];
$payment_method = mslib_fe::getPaymentMethod($this->post['tx_multishop_pi1']['pid'], 'p.id', $countries_id, true);
if ($payment_method['handling_costs']) {
    if (!strstr($payment_method['handling_costs'], "%")) {
        $payment_method_costs = $payment_method['handling_costs'];
    } else {
            $tmpcontent .= '<tr class="odd manual_add_new_product" style="display:none">';
            $tmpcontent .= '<td align="right">&nbsp;</td>
				<td align="right" valign="top">
					<input type="hidden" name="manual_product_name" id="product_name" value="">
					<input class="text" style="width:25px" type="text" name="manual_product_qty" id="manual_product_qty" value="1" tabindex="1" />
				</td>';
            $tmpcontent .= '<td align="left" valign="top" id="manual_add_product">
				<div id="manual_product_name_select2"><input class="product_name" type="hidden" name="manual_products_id" value="" style="width:400px" tabindex="2" /></div>';
            if ($this->ms['MODULES']['ENABLE_MANUAL_ORDER_CUSTOM_ORDER_PRODUCTS_NAME']) {
                $tmpcontent .= '<div id="custom_manual_product_name_wrapper" style="display:none"><label for="custom_manual_product_name">' . $this->pi_getLL('admin_custom_product_name') . ' :</label><input type="text" id="custom_manual_product_name" name="custom_manual_product_name" value="" disabled="disabled" width="300px" /></div>';
            }
            $tmpcontent .= '</td>';
            if ($this->ms['MODULES']['ADMIN_EDIT_ORDER_DISPLAY_ORDERS_PRODUCTS_STATUS'] > 0) {
                $tmpcontent .= '<td align="right">&nbsp;</td>';
            }
            $customer_country = mslib_fe::getCountryByName($orders['billing_country']);
            $sql_tax_sb = $GLOBALS['TYPO3_DB']->SELECTquery('t.tax_id, t.rate, t.name', 'tx_multishop_taxes t, tx_multishop_tax_rules tr, tx_multishop_tax_rule_groups trg', 't.tax_id=tr.tax_id and tr.rules_group_id=trg.rules_group_id and trg.status=1 and tr.cn_iso_nr=\'' . $customer_country['cn_iso_nr'] . '\'', '', '', '');
            $qry_tax_sb = $GLOBALS['TYPO3_DB']->sql_query($sql_tax_sb);
            $vat_sb = '<select name="manual_product_tax" id="product_tax">';
            $vat_sb .= '<option value="">' . $this->pi_getLL('admin_label_no_tax') . '</option>';
            while ($rs_tx_sb = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_tax_sb)) {
                $sb_tax_rate = $rs_tx_sb['rate'] / 100;
                if ($current_product_tax == $sb_tax_rate) {
                    $vat_sb .= '<option value="' . $rs_tx_sb['tax_id'] . '" selected="selected">' . $rs_tx_sb['name'] . '</option>';
                } else {
                    $vat_sb .= '<option value="' . $rs_tx_sb['tax_id'] . '">' . $rs_tx_sb['name'] . '</option>';
                }
            }
            $vat_sb .= '</select>';
            if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                $tmpcontent .= '<td align="right" class="cell_products_vat" valign="top">' . $vat_sb . '</td>';
Esempio n. 4
0
     echo json_encode($return_data);
     exit;
     break;
 case 'get_shoppingcart_shippingcost_overview':
     if ($this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT'] == '1') {
         $this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] = 1;
     }
     $return_data = array();
     if ($this->tta_user_info['default']['country']) {
         $iso_customer = mslib_fe::getCountryByName($this->tta_user_info['default']['country']);
     } else {
         $iso_customer = $this->tta_shop_info;
     }
     if (!$iso_customer['cn_iso_nr']) {
         // fall back (had issue with admin notification)
         $iso_customer = mslib_fe::getCountryByName($this->tta_shop_info['country']);
     }
     $delivery_country_id = $this->post['tx_multishop_pi1']['country_id'];
     $shipping_method_id = $this->post['tx_multishop_pi1']['shipping_method'];
     $shipping_cost_data = mslib_fe::getShoppingcartShippingCostsOverview($iso_customer['cn_iso_nr'], $delivery_country_id, $shipping_method_id);
     $count_cart_incl_vat = 0;
     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
         $count_cart_incl_vat = 1;
     }
     //
     $return_data['shipping_cost'] = 0;
     $return_data['shipping_costs_display'] = mslib_fe::amount2Cents(0);
     $return_data['shipping_method']['deliver_by'] = '';
     $return_data['shopping_cart_total_price'] = mslib_fe::amount2Cents(mslib_fe::countCartTotalPrice(1, $count_cart_incl_vat, $iso_customer['cn_iso_nr']));
     //
     foreach ($shipping_cost_data as $shipping_code => $shipping_cost) {
        $content .= '
		</ul>
		</div>
		';
    }
    if (count($shipping_methods)) {
        $content .= '
		<div id="multishopShippingMethodWrapper">
		<div class="main-heading"><h2>' . $this->pi_getLL('choose_shipping_method') . '</h2></div>
		<ul id="multishopShippingMethod" class="row">';
        $count = 0;
        $delivery_country = $cart['user']['country'];
        if (isset($cart['user']['different_delivery_address']) && !empty($cart['user']['different_delivery_address']) && isset($cart['user']['delivery_country']) && !empty($cart['user']['delivery_country'])) {
            $delivery_country = $cart['user']['delivery_country'];
        }
        $tmp_countries = mslib_fe::getCountryByName($delivery_country);
        $countries_id = $tmp_countries['cn_iso_nr'];
        foreach ($shipping_methods as $code => $item) {
            $shipping_method = mslib_fe::getShippingMethod($item['id'], 's.id', $countries_id);
            // custom hook that can be controlled by third-party plugin
            $shipping_method_description = '';
            if (!empty($item['description'])) {
                $shipping_method_description = '<div class="description">' . $item['description'] . '</div>';
            }
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/front_pages/includes/checkout/multistep/checkout_shipping_payment_method']['checkoutMultistepShippingMethodSelectionHook'])) {
                $params = array('shipping_method' => &$shipping_method, 'item' => &$item, 'shipping_method_description' => &$shipping_method_description);
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/front_pages/includes/checkout/multistep/checkout_shipping_payment_method']['checkoutMultistepShippingMethodSelectionHook'] as $funcRef) {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
                }
            }
            $count++;
Esempio n. 6
0
 function setPaymentMethod($payment_method)
 {
     if (!$payment_method) {
         return 0;
     }
     $payment_method = mslib_fe::getPaymentMethod($payment_method);
     $iso_customer = mslib_fe::getCountryByName($this->cart['user']['country']);
     $countries_id = $iso_customer['cn_iso_nr'];
     if ($payment_method['handling_costs']) {
         if (!strstr($payment_method['handling_costs'], "%")) {
             $this->cart['user']['payment_method_costs'] = $payment_method['handling_costs'];
         } else {
             // calculate total payment costs based by %
             if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                 $subtotal = $this->cart['summarize']['sub_total_including_vat'] - $this->cart['discount_amount'];
             } else {
                 $subtotal = $this->cart['summarize']['sub_total'] - $this->cart['discount_amount'];
             }
             if ($subtotal) {
                 if (strstr($payment_method['handling_costs'], "%")) {
                     $percentage = str_replace("%", '', $payment_method['handling_costs']);
                     $total_include_vat = 0;
                     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                         $total_include_vat = 1;
                     }
                     $subtotal = mslib_fe::countCartTotalPrice(1, $total_include_vat, $countries_id);
                     if ($subtotal) {
                         $handling_cost = $subtotal / 100 * $percentage;
                         if ($total_include_vat && $payment_method['tax_rate']) {
                             $handling_cost = $handling_cost / (1 + $payment_method['tax_rate']);
                         }
                         $this->cart['user']['payment_method_costs'] = $handling_cost;
                     }
                 } else {
                     $this->cart['user']['payment_method_costs'] = $payment_method['handling_costs'];
                 }
             }
         }
     } else {
         $this->cart['user']['payment_method_costs'] = 0;
     }
     if ($payment_method['tax_id'] && $this->cart['user']['payment_method_costs']) {
         $this->cart['user']['payment_total_tax_rate'] = $payment_method['tax_rate'];
         //if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
         //$this->cart['user']['payment_method_costs']=$this->cart['user']['payment_method_costs']-($this->cart['user']['payment_method_costs']*$this->cart['user']['payment_total_tax_rate']);
         //}
         if ($payment_method['country_tax_rate']) {
             $this->cart['user']['payment_country_tax_rate'] = $payment_method['country_tax_rate'];
             $this->cart['user']['payment_country_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['payment_method_costs'] * $payment_method['country_tax_rate']);
         } else {
             $this->cart['user']['payment_country_tax_rate'] = 0;
             $this->cart['user']['payment_country_tax'] = 0;
         }
         if ($payment_method['region_tax_rate']) {
             $this->cart['user']['payment_region_tax_rate'] = $payment_method['region_tax_rate'];
             $this->cart['user']['payment_region_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['payment_method_costs'] * $payment_method['region_tax_rate']);
         } else {
             $this->cart['user']['payment_region_tax_rate'] = 0;
             $this->cart['user']['payment_region_tax'] = 0;
         }
         if ($this->cart['user']['payment_region_tax'] && $this->cart['user']['payment_country_tax']) {
             $this->cart['user']['payment_tax'] = $this->cart['user']['payment_country_tax'] + $this->cart['user']['payment_region_tax'];
         } else {
             $this->cart['user']['payment_tax'] = $this->cart['user']['payment_method_costs'] * $payment_method['tax_rate'];
         }
     } else {
         $this->cart['user']['payment_tax'] = 0;
         $this->cart['user']['payment_country_tax'] = 0;
         $this->cart['user']['payment_region_tax'] = 0;
         $this->cart['user']['payment_total_tax_rate'] = 0;
         $this->cart['user']['payment_country_tax_rate'] = 0;
         $this->cart['user']['payment_region_tax_rate'] = 0;
     }
     $this->cart['user']['payment_method'] = $payment_method['code'];
     $this->cart['user']['payment_method_label'] = $payment_method['name'];
     // payment eof
     // hook to rewrite the whole methods
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_cart.php']['setPaymentMethodPreSaveHook'])) {
         $params = array('cart_user' => &$this->cart['user']);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_cart.php']['setPaymentMethodPreSaveHook'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     tx_mslib_cart::storeCart($this->cart);
 }
 function createOrder($address)
 {
     if (is_numeric($address['uid'])) {
         $customer_id = $address['uid'];
     } else {
         if (!$address['email']) {
             return false;
         }
         $tmp_user = mslib_fe::getUser($address['email'], 'email');
         if ($tmp_user['uid']) {
             $customer_id = $tmp_user['uid'];
         }
     }
     if (!$customer_id) {
         // add new account
         $insertArray = array();
         $insertArray['page_uid'] = $this->shop_pid;
         $insertArray['company'] = $address['company'];
         $insertArray['name'] = $address['first_name'] . ' ' . $address['middle_name'] . ' ' . $address['last_name'];
         $insertArray['name'] = preg_replace('/\\s+/', ' ', $insertArray['name']);
         $insertArray['first_name'] = $address['first_name'];
         $insertArray['last_name'] = $address['last_name'];
         $insertArray['username'] = $address['email'];
         $insertArray['email'] = $address['email'];
         $insertArray['street_name'] = $address['street_name'];
         if (!$insertArray['street_name']) {
             $insertArray['street_name'] = $address['address'];
         }
         $insertArray['address_number'] = $address['address_number'];
         $insertArray['address_ext'] = $address['address_ext'];
         if ($address['address']) {
             $insertArray['address'] = $address['address'];
         } else {
             $insertArray['address'] = $insertArray['street_name'] . ' ' . $insertArray['address_number'] . $insertArray['address_ext'];
             $insertArray['address'] = preg_replace('/\\s+/', ' ', $insertArray['address']);
         }
         $insertArray['zip'] = $address['zip'];
         $insertArray['telephone'] = $address['telephone'];
         $insertArray['city'] = $address['city'];
         $insertArray['country'] = $address['country'];
         $insertArray['usergroup'] = $this->conf['fe_customer_usergroup'];
         $insertArray['pid'] = $this->conf['fe_customer_pid'];
         $insertArray['tstamp'] = time();
         $insertArray['tx_multishop_newsletter'] = $address['tx_multishop_newsletter'];
         $insertArray['password'] = mslib_befe::getHashedPassword(mslib_befe::generateRandomPassword(10, $insertArray['username']));
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('fe_users', $insertArray);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
         if ($res) {
             $customer_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
         }
     }
     if ($customer_id) {
         if ($this->ms['MODULES']['DISABLE_VAT_FOR_FOREIGN_CUSTOMERS_WITH_COMPANY_VAT_ID']) {
             // if store country is different than customer country change VAT rate to zero
             if ($address['country'] && $address['tx_multishop_vat_id']) {
                 $iso_customer = mslib_fe::getCountryByName($address['country']);
                 if ($iso_customer['cn_iso_nr'] != $this->ms['MODULES']['COUNTRY_ISO_NR']) {
                     $this->ms['MODULES']['DISABLE_VAT_RATE'] = 1;
                 }
             }
             // if store country is different than customer country change VAT rate to zero eof
         }
         // now add the order
         $insertArray = array();
         $insertArray['customer_id'] = $customer_id;
         $insertArray['page_uid'] = $this->shop_pid;
         $insertArray['language_id'] = 0;
         if (is_numeric($address['language_id'])) {
             $insertArray['language_id'] = $address['language_id'];
         }
         $insertArray['status'] = '';
         if (isset($address['status']) && $address['status'] > 0) {
             // Set order status
             $insertArray['status'] = $address['status'];
         } else {
             // get default orders status
             $status = mslib_fe::getDefaultOrdersStatus($this->sys_language_uid);
             if (is_array($status) && isset($status['id']) && $status['id'] > 0) {
                 $insertArray['status'] = $status['id'];
             }
         }
         $insertArray['customer_comments'] = $this->post['customer_comments'];
         $insertArray['billing_company'] = $address['company'];
         $insertArray['billing_first_name'] = $address['first_name'];
         $insertArray['billing_middle_name'] = $address['middle_name'];
         $insertArray['billing_last_name'] = $address['last_name'];
         $insertArray['billing_name'] = preg_replace('/ +/', ' ', $address['first_name'] . ' ' . $address['middle_name'] . ' ' . $address['last_name']);
         $insertArray['billing_email'] = $address['email'];
         $insertArray['billing_gender'] = $address['gender'];
         $insertArray['billing_birthday'] = $address['birthday'];
         if (!$address['street_name']) {
             $address['street_name'] = $address['address'];
         }
         $insertArray['billing_building'] = $address['building'];
         $insertArray['billing_street_name'] = $address['street_name'];
         $insertArray['billing_address_number'] = $address['address_number'];
         $insertArray['billing_address_ext'] = $address['address_ext'];
         $insertArray['billing_address'] = $address['street_name'] . ' ' . $address['address_number'] . $address['address_ext'];
         $insertArray['billing_address'] = preg_replace('/\\s+/', ' ', $insertArray['billing_address']);
         $insertArray['billing_room'] = '';
         $insertArray['billing_city'] = $address['city'];
         $insertArray['billing_zip'] = $address['zip'];
         $insertArray['billing_region'] = $address['state'];
         $insertArray['billing_country'] = $address['country'];
         $insertArray['billing_telephone'] = $address['telephone'];
         $insertArray['billing_mobile'] = $address['mobile'];
         $insertArray['billing_fax'] = '';
         $insertArray['billing_vat_id'] = $address['tx_multishop_vat_id'];
         if (!$address['different_delivery_address']) {
             $insertArray['delivery_email'] = $insertArray['billing_email'];
             $insertArray['delivery_company'] = $insertArray['billing_company'];
             $insertArray['delivery_first_name'] = $insertArray['billing_first_name'];
             $insertArray['delivery_middle_name'] = $insertArray['billing_middle_name'];
             $insertArray['delivery_last_name'] = $insertArray['billing_last_name'];
             $insertArray['delivery_telephone'] = $insertArray['billing_telephone'];
             $insertArray['delivery_mobile'] = $insertArray['billing_mobile'];
             $insertArray['delivery_gender'] = $insertArray['billing_gender'];
             $insertArray['delivery_building'] = $insertArray['billing_building'];
             $insertArray['delivery_street_name'] = $insertArray['billing_street_name'];
             $insertArray['delivery_address'] = $insertArray['billing_address'];
             $insertArray['delivery_address_number'] = $insertArray['billing_address_number'];
             $insertArray['delivery_address_ext'] = $insertArray['billing_address_ext'];
             $insertArray['delivery_zip'] = $insertArray['billing_zip'];
             $insertArray['delivery_city'] = $insertArray['billing_city'];
             $insertArray['delivery_country'] = $insertArray['billing_country'];
             $insertArray['delivery_telephone'] = $insertArray['billing_telephone'];
             $insertArray['delivery_region'] = $insertArray['billing_region'];
             $insertArray['delivery_name'] = $insertArray['billing_name'];
             $insertArray['delivery_vat_id'] = $insertArray['billing_vat_id'];
         } else {
             $insertArray['delivery_company'] = $address['delivery_company'];
             $insertArray['delivery_first_name'] = $address['delivery_first_name'];
             $insertArray['delivery_middle_name'] = $address['delivery_middle_name'];
             $insertArray['delivery_last_name'] = $address['delivery_last_name'];
             $insertArray['delivery_name'] = preg_replace('/ +/', ' ', $address['delivery_first_name'] . ' ' . $address['delivery_middle_name'] . ' ' . $address['delivery_last_name']);
             $insertArray['delivery_email'] = $address['delivery_email'];
             $insertArray['delivery_gender'] = $address['delivery_gender'];
             if (!$address['delivery_street_name']) {
                 $address['delivery_street_name'] = $address['delivery_address'];
             }
             $insertArray['delivery_building'] = $address['delivery_building'];
             $insertArray['delivery_street_name'] = $address['delivery_street_name'];
             $insertArray['delivery_address_number'] = $address['delivery_address_number'];
             $insertArray['delivery_address_ext'] = $address['delivery_address_ext'];
             $insertArray['delivery_address'] = $address['delivery_street_name'] . ' ' . $address['delivery_address_number'] . $address['delivery_address_ext'];
             $insertArray['delivery_address'] = preg_replace('/\\s+/', ' ', $insertArray['delivery_address']);
             $insertArray['delivery_city'] = $address['delivery_city'];
             $insertArray['delivery_zip'] = $address['delivery_zip'];
             $insertArray['delivery_room'] = '';
             $insertArray['delivery_region'] = $address['delivery_state'];
             $insertArray['delivery_country'] = $address['delivery_country'];
             $insertArray['delivery_telephone'] = $address['delivery_telephone'];
             $insertArray['delivery_mobile'] = $address['delivery_mobile'];
             $insertArray['delivery_fax'] = '';
             $insertArray['delivery_vat_id'] = $address['delivery_vat_id'];
         }
         $insertArray['bill'] = 1;
         if ($address['forceCustomCrdate']) {
             $insertArray['crdate'] = $address['forceCustomCrdate'];
         } else {
             $insertArray['crdate'] = time();
         }
         $insertArray['shipping_method'] = $address['shipping_method'];
         $insertArray['shipping_method_label'] = $address['shipping_method_label'];
         $insertArray['payment_method'] = $address['payment_method'];
         $insertArray['payment_method_label'] = $address['payment_method_label'];
         $insertArray['shipping_method_costs'] = $address['shipping_method_costs'];
         $insertArray['payment_method_costs'] = $address['payment_method_costs'];
         $insertArray['payment_condition'] = $address['payment_condition'];
         $insertArray['debit_order'] = 0;
         if (isset($address['debit_order'])) {
             $insertArray['debit_order'] = $address['debit_order'];
         }
         $insertArray['store_currency'] = $this->ms['MODULES']['CURRENCY_ARRAY']['cu_iso_3'];
         $insertArray['customer_currency'] = $this->ms['MODULES']['CURRENCY_ARRAY']['cu_iso_3'];
         if (isset($address['customer_currency']) && $address['customer_currency'] != '') {
             $insertArray['customer_currency'] = $address['customer_currency'];
         }
         $insertArray['currency_rate'] = 1;
         if (isset($address['currency_rate']) && $address['currency_rate'] != '') {
             $insertArray['currency_rate'] = $address['currency_rate'];
         }
         // TYPO3 6.2 NULL VALUE BUGFIX
         if (!$insertArray['customer_comments']) {
             $insertArray['customer_comments'] = '';
         }
         $insertArray['hash'] = md5(uniqid('', true));
         if (isset($address['foreign_source_name'])) {
             $insertArray['foreign_source_name'] = $address['foreign_source_name'];
         }
         if (isset($address['foreign_orders_id'])) {
             $insertArray['foreign_orders_id'] = $address['foreign_orders_id'];
         }
         if (isset($address['http_referer'])) {
             $insertArray['http_referer'] = $address['http_referer'];
         }
         if (isset($address['expected_delivery_date'])) {
             $insertArray['expected_delivery_date'] = $address['expected_delivery_date'];
         }
         $types = array();
         $types[] = 'billing';
         $types[] = 'delivery';
         foreach ($types as $type) {
             $str2 = 'select st.* from static_countries sc, static_territories st where sc.cn_short_en=\'' . addslashes($insertArray[$type . '_country']) . '\' and st.tr_iso_nr=sc.cn_parent_tr_iso_nr';
             $query2 = $GLOBALS['TYPO3_DB']->sql_query($str2);
             $rows2 = $GLOBALS['TYPO3_DB']->sql_num_rows($query2);
             if ($rows2) {
                 $row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query2);
                 $insertArray[$type . '_tr_iso_nr'] = $row2['tr_iso_nr'];
                 $insertArray[$type . '_tr_name_en'] = $row2['tr_name_en'];
                 $str2 = 'select * from static_territories where tr_iso_nr=' . $row2['tr_parent_iso_nr'];
                 $query2 = $GLOBALS['TYPO3_DB']->sql_query($str2);
                 $rows2 = $GLOBALS['TYPO3_DB']->sql_num_rows($query2);
                 if ($rows2) {
                     $row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query2);
                     $insertArray[$type . '_tr_parent_iso_nr'] = $row2['tr_iso_nr'];
                     $insertArray[$type . '_tr_parent_name_en'] = $row2['tr_name_en'];
                 }
             }
         }
         //hook to let other plugins further manipulate the replacers
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_order.php']['createOrderPreProc'])) {
             $params = array('insertArray' => &$insertArray);
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_order.php']['createOrderPreProc'] as $funcRef) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
             }
         }
         foreach ($insertArray as $key => $val) {
             if (is_null($insertArray[$key])) {
                 $insertArray[$key] = '';
             }
         }
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_orders', $insertArray);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
         // now add the order eof
         $orders_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
         //hook to let other plugins further manipulate the replacers
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_order.php']['createOrderPostProc'])) {
             $params = array('insertArray' => &$insertArray, 'orders_id' => &$orders_id);
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_order.php']['createOrderPostProc'] as $funcRef) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
             }
         }
         if ($orders_id) {
             return $orders_id;
         }
     }
 }