// 기준 시간을 초과한 경우 체크
if ($cart_stock_limit > 0) {
    if ($cart_stock_limit > $keep_term * 24) {
        $cart_stock_limit = $keep_term * 24;
    }
    $stocktime = G5_SERVER_TIME - 3600 * $cart_stock_limit;
    $sql = " select count(*) as cnt\n                from {$g5['g5_shop_cart_table']}\n                where od_id = '{$tmp_cart_id}'\n                  and ct_status = '쇼핑'\n                  and ct_select = '1'\n                  and UNIX_TIMESTAMP(ct_select_time) > '{$stocktime}' ";
    $row = sql_fetch($sql);
    if (!$row['cnt']) {
        die("주문 요청 때까지 " . $cart_stock_limit . "시간 이상 경과되어 주문 상품이 초기화 됐습니다.\n\n 장바구니에서 주문하실 상품을 다시 확인해 주십시오.");
    }
}
// 재고체크
$sql = " select *\n            from {$g5['g5_shop_cart_table']}\n            where od_id = '{$tmp_cart_id}'\n              and ct_select = '1'\n              and ct_status = '쇼핑' ";
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
    $ct_qty = $row['ct_qty'];
    if (!$row['io_id']) {
        $it_stock_qty = get_it_stock_qty($row['it_id']);
    } else {
        $it_stock_qty = get_option_stock_qty($row['it_id'], $row['io_id'], $row['io_type']);
    }
    if ($ct_qty > $it_stock_qty) {
        $item_option = $row['it_name'];
        if ($row['io_id']) {
            $item_option .= '(' . $row['ct_option'] . ')';
        }
        die($item_option . " 의 재고수량이 부족합니다.\n\n현재 재고수량 : " . number_format($it_stock_qty) . " 개");
    }
}
die("");
    $tmp_cart_id = get_session('ss_cart_id');
}
if (get_cart_count($tmp_cart_id) == 0) {
    // 장바구니에 담기
    alert('장바구니가 비어 있습니다.\\n\\n이미 주문하셨거나 장바구니에 담긴 상품이 없는 경우입니다.', G5_SHOP_URL . '/cart.php');
}
$error = "";
// 장바구니 상품 재고 검사
$sql = " select it_id,\n                ct_qty,\n                it_name,\n                io_id,\n                io_type,\n                ct_option\n           from {$g5['g5_shop_cart_table']}\n          where od_id = '{$tmp_cart_id}'\n            and ct_select = '1' ";
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
    // 상품에 대한 현재고수량
    if ($row['io_id']) {
        $it_stock_qty = (int) get_option_stock_qty($row['it_id'], $row['io_id'], $row['io_type']);
    } else {
        $it_stock_qty = (int) get_it_stock_qty($row['it_id']);
    }
    // 장바구니 수량이 재고수량보다 많다면 오류
    if ($row['ct_qty'] > $it_stock_qty) {
        $error .= "{$row['ct_option']} 의 재고수량이 부족합니다. 현재고수량 : {$it_stock_qty} 개\\n\\n";
    }
}
if ($i == 0) {
    alert('장바구니가 비어 있습니다.\\n\\n이미 주문하셨거나 장바구니에 담긴 상품이 없는 경우입니다.', G5_SHOP_URL . '/cart.php');
}
if ($error != "") {
    $error .= "다른 고객님께서 {$od_name}님 보다 먼저 주문하신 경우입니다. 불편을 끼쳐 죄송합니다.";
    alert($error);
}
$i_price = (int) $_POST['od_price'];
$i_send_cost = (int) $_POST['od_send_cost'];
Exemple #3
0
function is_soldout($it_id)
{
    global $g5;
    // 상품정보
    $sql = " select it_soldout, it_stock_qty from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' ";
    $it = sql_fetch($sql);
    if ($it['it_soldout'] || $it['it_stock_qty'] <= 0) {
        return true;
    }
    $count = 0;
    $soldout = false;
    // 상품에 선택옵션 있으면..
    $sql = " select count(*) as cnt from {$g5['g5_shop_item_option_table']} where it_id = '{$it_id}' and io_type = '0' ";
    $row = sql_fetch($sql);
    if ($row['cnt']) {
        $sql = " select io_id, io_type, io_stock_qty\n                    from {$g5['g5_shop_item_option_table']}\n                    where it_id = '{$it_id}'\n                      and io_type = '0'\n                      and io_use = '1' ";
        $result = sql_query($sql);
        for ($i = 0; $row = sql_fetch_array($result); $i++) {
            // 옵션 재고수량
            $stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']);
            if ($stock_qty <= 0) {
                $count++;
            }
        }
        // 모든 선택옵션 품절이면 상품 품절
        if ($i == $count) {
            $soldout = true;
        }
    } else {
        // 상품 재고수량
        $stock_qty = get_it_stock_qty($it_id);
        if ($stock_qty <= 0) {
            $soldout = true;
        }
    }
    return $soldout;
}
Exemple #4
0
     if ((int) $io_price < 0) {
         die('구매금액이 음수인 상품은 구매할 수 없습니다.');
     }
 } else {
     if ((int) $it['it_price'] + (int) $io_price < 0) {
         die('구매금액이 음수인 상품은 구매할 수 없습니다.');
     }
 }
 // 동일옵션의 상품이 있으면 수량 더함
 $sql2 = " select ct_id\n                    from {$g5['g5_shop_cart_table']}\n                    where od_id = '{$tmp_cart_id}'\n                      and it_id = '{$it_id}'\n                      and io_id = '{$io_id}'\n                      and ct_status = '쇼핑' ";
 $row2 = sql_fetch($sql2);
 if ($row2['ct_id']) {
     // 재고체크
     $tmp_ct_qty = $row2['ct_qty'];
     if (!$io_id) {
         $tmp_it_stock_qty = get_it_stock_qty($it_id);
     } else {
         $tmp_it_stock_qty = get_option_stock_qty($it_id, $io_id, $row2['io_type']);
     }
     if ($tmp_ct_qty + $ct_qty > $tmp_it_stock_qty) {
         die($io_value . " 의 재고수량이 부족합니다.\\n\\n현재 재고수량 : " . number_format($tmp_it_stock_qty) . " 개");
     }
     $sql3 = " update {$g5['g5_shop_cart_table']}\n\t\t\t\t\t\tset ct_qty = ct_qty + '{$ct_qty}'\n\t\t\t\t\t\twhere ct_id = '{$row2['ct_id']}' ";
     sql_query($sql3);
     continue;
 }
 // 포인트
 $point = 0;
 if ($config['cf_use_point']) {
     if ($io_type == 0) {
         $point = get_item_point($it, $io_id);