} else {
        $customers_ip = $_SERVER['REMOTE_ADDR'];
    }
    $smarty->assign('CUSTOMERS_IP', $customers_ip);
}
$smarty->assign('FORM_SHIPPING_ACTION', xtc_draw_form('checkout_shipping', xtc_href_link(FILENAME_PAYPAL_CHECKOUT, '', 'SSL')) . xtc_draw_hidden_field('action', 'process'));
$smarty->assign('ADDRESS_SHIPPING_LABEL', xtc_address_label($_SESSION['customer_id'], $_SESSION['sendto'], true, ' ', '<br />'));
$smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE));
$smarty->assign('FORM_END', '</form>');
$smarty->assign('ADDRESS_PAYMENT_LABEL', xtc_address_label($_SESSION['customer_id'], $_SESSION['billto'], true, ' ', '<br />'));
if (PAYPAL_EXPRESS_ADDRESS_CHANGE == 'true') {
    $smarty->assign('BUTTON_SHIPPING_ADDRESS', '<a href="' . xtc_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . xtc_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>');
    $smarty->assign('BUTTON_PAYMENT_ADDRESS', '<a href="' . xtc_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . xtc_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>');
}
$module_smarty = new Smarty();
if (xtc_count_shipping_modules() > 0) {
    $showtax = $_SESSION['customers_status']['customers_status_show_price_tax'];
    $module_smarty->assign('FREE_SHIPPING', $free_shipping);
    # free shipping or not...
    if ($free_shipping == true) {
        $module_smarty->assign('FREE_SHIPPING_TITLE', FREE_SHIPPING_TITLE);
        $module_smarty->assign('FREE_SHIPPING_DESCRIPTION', sprintf(FREE_SHIPPING_DESCRIPTION, $xtPrice->xtcFormat(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER, true, 0, true)) . xtc_draw_hidden_field('shipping', 'free_free'));
        $module_smarty->assign('FREE_SHIPPING_ICON', $quotes[$i]['icon']);
    } else {
        $radio_buttons = 0;
        #loop through installed shipping methods...
        //BOF - DokuMan - 2011-12-19 - precount for performance
        //for($i = 0, $n = sizeof($quotes); $i < $n; $i ++) {
        $n = sizeof($quotes);
        for ($i = 0; $i < $n; $i++) {
            //EOF - DokuMan - 2011-12-19 - precount for performance
 function confirmation()
 {
     global $order, $smarty, $xtPrice, $main, $messageStack, $total_weight, $total_count, $free_shipping;
     if (isset($_GET['conditions_message'])) {
         $message_condition = str_replace('\\n', '', ERROR_CONDITIONS_NOT_ACCEPTED);
         $message_address = str_replace('\\n', '', ERROR_ADDRESS_NOT_ACCEPTED);
         switch ($_GET['conditions_message']) {
             case "1":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 break;
             case "13":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
             case "2":
                 $messageStack->add('checkout_confirmation', $message_address);
                 break;
             case "23":
                 $messageStack->add('checkout_confirmation', $message_address);
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
             case "12":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 $messageStack->add('checkout_confirmation', $message_address);
                 break;
             case "123":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 $messageStack->add('checkout_confirmation', $message_address);
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
             case "3":
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
         }
     }
     if ($order->delivery['country']['iso_code_2'] != '') {
         $_SESSION['delivery_zone'] = $order->delivery['country']['iso_code_2'];
     }
     $no_shipping = false;
     if ($order->content_type == 'virtual' || $order->content_type == 'virtual_weight' || $_SESSION['cart']->count_contents_virtual() == 0) {
         $no_shipping = true;
     }
     $total_weight = $_SESSION['cart']->show_weight();
     $total_count = $_SESSION['cart']->count_contents();
     // load all enabled shipping modules
     $shipping_modules = new shipping();
     // add unallowed payment / shipping
     if (defined('MODULE_EXCLUDE_PAYMENT_STATUS') && MODULE_EXCLUDE_PAYMENT_STATUS == 'True') {
         for ($i = 1; $i <= MODULE_EXCLUDE_PAYMENT_NUMBER; $i++) {
             $payment_exclude = explode(',', constant('MODULE_EXCLUDE_PAYMENT_PAYMENT_' . $i));
             if (in_array($this->code, $payment_exclude)) {
                 $shipping_exclude = explode(',', constant('MODULE_EXCLUDE_PAYMENT_SHIPPING_' . $i));
                 for ($i = 0, $n = count($shipping_modules->modules); $i < $n; $i++) {
                     if (in_array(substr($shipping_modules->modules[$i], 0, -4), $shipping_exclude)) {
                         unset($shipping_modules->modules[$i]);
                     }
                 }
             }
         }
     }
     $free_shipping = false;
     $ot_shipping = new ot_shipping();
     $ot_shipping->process();
     if ($no_shipping === true) {
         $_SESSION['shipping'] = false;
     }
     // get all available shipping quotes
     $quotes = $shipping_modules->quote();
     // if no shipping method has been selected, automatically select the cheapest method.
     // if the modules status was changed when none were available, to save on implementing
     // a javascript force-selection method, also automatically select the cheapest shipping
     // method if more than one module is now enabled
     if (!isset($_SESSION['shipping']) && CHECK_CHEAPEST_SHIPPING_MODUL == 'true' || isset($_SESSION['shipping']) && $_SESSION['shipping'] == false && xtc_count_shipping_modules() > 1) {
         $_SESSION['shipping'] = $shipping_modules->cheapest();
     }
     if ($no_shipping === true) {
         $_SESSION['shipping'] = false;
     }
     if (defined('SHOW_SELFPICKUP_FREE') && SHOW_SELFPICKUP_FREE == 'true') {
         if ($free_shipping == true) {
             $free_shipping = false;
             $quotes = array_merge($ot_shipping->quote(), $shipping_modules->quote('selfpickup', 'selfpickup'));
         }
     }
     $module_smarty = new Smarty();
     $shipping_block = '';
     if (xtc_count_shipping_modules() > 0) {
         $showtax = $_SESSION['customers_status']['customers_status_show_price_tax'];
         $module_smarty->assign('FREE_SHIPPING', $free_shipping);
         # free shipping or not...
         if ($free_shipping == true) {
             $module_smarty->assign('FREE_SHIPPING_TITLE', FREE_SHIPPING_TITLE);
             $module_smarty->assign('FREE_SHIPPING_DESCRIPTION', sprintf(FREE_SHIPPING_DESCRIPTION, $xtPrice->xtcFormat($free_shipping_value_over, true, 0, true)) . xtc_draw_hidden_field('shipping', 'free_free'));
             $module_smarty->assign('FREE_SHIPPING_ICON', $quotes[$i]['icon']);
         } else {
             $radio_buttons = 0;
             #loop through installed shipping methods...
             for ($i = 0, $n = sizeof($quotes); $i < $n; $i++) {
                 if (!isset($quotes[$i]['error'])) {
                     for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) {
                         # set the radio button to be checked if it is the method chosen
                         $quotes[$i]['methods'][$j]['radio_buttons'] = $radio_buttons;
                         $checked = isset($_SESSION['shipping']) && $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id'] ? true : false;
                         if ($checked == true || $n == 1 && $n2 == 1) {
                             $quotes[$i]['methods'][$j]['checked'] = 1;
                         }
                         if ($n > 1 || $n2 > 1) {
                             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 || !isset($quotes[$i]['tax'])) {
                                 $quotes[$i]['tax'] = 0;
                             }
                             $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']), true, 0, true);
                             $quotes[$i]['methods'][$j]['radio_field'] = xtc_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'id="rd-' . ($i + 1) . '" onChange="this.form.submit()"');
                         } else {
                             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0) {
                                 $quotes[$i]['tax'] = 0;
                             }
                             $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0), true, 0, true) . xtc_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']);
                         }
                         $radio_buttons++;
                     }
                 }
             }
             $module_smarty->assign('module_content', $quotes);
         }
         $module_smarty->assign('language', $_SESSION['language']);
         $module_smarty->caching = 0;
         $shipping_block = $module_smarty->fetch(CURRENT_TEMPLATE . '/module/checkout_shipping_block.html');
     }
     if ($no_shipping === false) {
         $module_smarty->assign('FORM_SHIPPING_ACTION', xtc_draw_form('checkout_shipping', xtc_href_link(FILENAME_CHECKOUT_CONFIRMATION, xtc_get_all_get_params(), 'SSL')) . xtc_draw_hidden_field('action', 'process'));
         $shipping_found = false;
         for ($i = 0, $n = sizeof($quotes); $i < $n; $i++) {
             for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) {
                 if ($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id']) {
                     $shipping_found = true;
                     break;
                 }
             }
         }
         if ($shipping_found === false) {
             $module_smarty->assign('shipping_message', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
             /*
             if (xtc_count_shipping_modules() == 1) {
               $module_smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_confirm.gif', IMAGE_BUTTON_CONFIRM));
             }
             */
         }
         $module_smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_confirm.gif', IMAGE_BUTTON_CONFIRM));
         $module_smarty->assign('FORM_END', '</form>');
         if ($no_shipping === false) {
             $module_smarty->assign('SHIPPING_BLOCK', $shipping_block);
         }
         $module_smarty->assign('language', $_SESSION['language']);
         $module_smarty->caching = 0;
         $shipping_method = $module_smarty->fetch(DIR_FS_EXTERNAL . '/paypal/templates/shipping_block.html');
         $smarty->assign('SHIPPING_METHOD', $shipping_method);
     }
     $smarty->assign('SHIPPING_ADDRESS_EDIT', xtc_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, xtc_get_all_get_params(), 'SSL'));
     $smarty->assign('BILLING_ADDRESS_EDIT', xtc_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, xtc_get_all_get_params(), 'SSL'));
     $smarty->clear_assign('SHIPPING_EDIT');
     $smarty->clear_assign('PAYMENT_EDIT');
     //$smarty->clear_assign('PRODUCTS_EDIT');
 }