require_once DIR_FS_INC . 'olc_get_address_format_id.inc.php';
require_once DIR_FS_INC . 'olc_draw_radio_field.inc.php';
require_once DIR_FS_INC . 'olc_draw_textarea_field.inc.php';
require_once DIR_FS_INC . 'olc_draw_checkbox_field.inc.php';
require_once DIR_FS_INC . 'olc_draw_hidden_field.inc.php';
require_once DIR_FS_INC . 'olc_check_stock.inc.php';
unset($_SESSION['paypal_payment']);
unset($_SESSION['credit_covers']);
//ICW ADDED FOR CREDIT CLASS SYSTEM
// Stock Check
if (STOCK_CHECK == TRUE_STRING_S) {
    if (STOCK_ALLOW_CHECKOUT != TRUE_STRING_S) {
        $products = $_SESSION['cart']->get_products();
        $any_out_of_stock = 0;
        for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
            if (olc_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
                $any_out_of_stock = 1;
            }
        }
        if ($any_out_of_stock == 1) {
            olc_redirect(olc_href_link(FILENAME_SHOPPING_CART));
        }
    }
}
//---PayPal WPP Modification START ---//
$ec_enabled = olc_paypal_wpp_enabled();
if ($ec_enabled) {
    if ($_SESSION['paypal_error']) {
        $checkout_login = true;
        $messageStack->add('payment', $paypal_error);
        unset($_SESSION['paypal_error']);
 $link = '    <td valign="top" class="main"><a href="' . olc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';
 if ($is_shopping_cart) {
     if ($product_list_model) {
         echo $link . $products[$i]['model'] . '</a></td>' . NEW_LINE;
     }
 }
 // Product name, with or without link
 if ($is_shopping_cart) {
     echo $link . HTML_B_START . $products[$i]['name'] . '</b></a>';
 } else {
     echo '    <td valign="top" class="main"><b>' . $products[$i]['name'] . HTML_B_END;
 }
 // Display marker if stock quantity insufficient
 if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
     if (STOCK_CHECK == TRUE_STRING_S) {
         echo $stock_check = olc_check_stock($products[$i]['id'], $products[$i]['quantity']);
         if ($stock_check) {
             $any_out_of_stock = 1;
         }
     }
 }
 // Product options names
 $attributes_exist = isset($products[$i]['attributes']) ? 1 : 0;
 if ($attributes_exist == 1) {
     reset($products[$i]['attributes']);
     while (list($option, $value) = each($products[$i]['attributes'])) {
         echo '<br/><small><i> - ' . $products[$i][$option]['products_options_model'] . '  ' . $products[$i][$option]['products_options_name'] . BLANK . $products[$i][$option]['products_options_values_name'] . '</i></small>';
         // Display marker if attributes-stock quantity insufficient
         if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
             if (ATTRIBUTE_STOCK_CHECK == TRUE_STRING_S) {
                 echo $attribute_stock_check = olc_check_stock_attributes($products[$i][$option]['attributes_stock'], $products[$i]['quantity']);
    $ebay_image = HTML_NBSP . olc_image(DIR_WS_IMAGES . "ebay.gif", AUCTIONS_TEXT_SHOW_PRODUCT, EMPTY_STRING, EMPTY_STRING, ' align="middle"');
    $ebay_link = olc_href_link(EBAY_SERVER, EBAY_VIEWITEM . HASH) . '" target="_blank';
    $hidden_quantity = olc_draw_hidden_field($cart_quantity_text, HASH);
    $hidden_product_id = olc_draw_hidden_field($products_id_text, HASH);
}
$link = olc_href_link(FILENAME_PRODUCT_INFO, $products_id_equal_text . HASH);
$do_stock_check = STOCK_CHECK == TRUE_STRING_S;
$do_atribute_stock_check = $do_stock_check && ATTRIBUTE_STOCK_CHECK == TRUE_STRING_S;
for ($i = 0; $i < sizeof($products); $i++) {
    $product = $products[$i];
    $product_id = $product[$id_text];
    $products_quantity = $product[$quantity_text];
    $products_min_quantity = $product[$min_quantity_text];
    $products_quantity = max($products_quantity, $products_min_quantity);
    if ($do_stock_check) {
        $mark_stock = olc_check_stock($product_id, $products_quantity);
        $_SESSION[$any_out_of_stock_text] = $mark_stock;
        $mark_stock = HTML_NBSP . $mark_stock;
    }
    $image = $product[$image_text];
    if ($image) {
        $image = DIR_WS_THUMBNAIL_IMAGES . $image;
    }
    $price_single = olc_get_products_price($product_id, $price_special = 1, $quantity = 1, $price_real);
    $price_single = abs($price_real);
    $total_price = olc_format_price($price_single * $products_quantity, 1, 1);
    if ($show_saved_cart) {
        $products_qty = $products_quantity;
    } else {
        if (USE_AJAX) {
            $parameter = str_replace(HASH, $i, $parameter0);
// GV Code line changed
if (is_array($payment_modules->modules) && sizeof($payment_modules->modules) > 1 && !is_object(${$_SESSION}['payment']) && !isset($_SESSION['credit_covers']) || is_object(${$_SESSION}['payment']) && !${$_SESSION}['payment']->enabled) {
    olc_redirect(olc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), SSL));
}
if (is_array($payment_modules->modules)) {
    $payment_modules->pre_confirmation_check();
}
// load the selected shipping module
require_once DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping($_SESSION['shipping']);
// Stock Check
$any_out_of_stock = false;
if (STOCK_CHECK == TRUE_STRING_S) {
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
        $order_products = $order->products[$i];
        if (olc_check_stock($order_products['id'], $order_products['qty'])) {
            $any_out_of_stock = true;
            break;
        }
    }
    // Out of Stock
    if (STOCK_ALLOW_CHECKOUT != TRUE_STRING_S) {
        if ($any_out_of_stock) {
            olc_redirect(olc_href_link(FILENAME_SHOPPING_CART));
        }
    }
}
require DIR_WS_INCLUDES . 'header.php';
//
// Kunden-IP-Adresse
//