장바구니 옵션 수정기능 추가 및 옵션 출력 코드 수정

This commit is contained in:
chicpro
2013-05-28 11:19:05 +09:00
parent fb8d96ae9a
commit 2c052fc63d
12 changed files with 50 additions and 67 deletions

View File

@ -74,6 +74,7 @@ CREATE TABLE IF NOT EXISTS `shop_cart` (
`ct_ip` varchar(25) NOT NULL DEFAULT '',
`ct_send_cost` varchar(255) NOT NULL,
`ct_direct` tinyint(4) NOT NULL,
`ct_order` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ct_id`),
KEY `uq_id` (`uq_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -683,14 +683,17 @@ function print_item_options($it_id, $uq_id)
{
global $g4;
$sql = " select ct_option from {$g4['shop_cart_table']} where it_id = '$it_id' and uq_id = '$uq_id' order by io_type asc, ct_num asc, ct_id asc ";
$sql = " select ct_option, ct_qty
from {$g4['shop_cart_table']}
where it_id = '$it_id' and uq_id = '$uq_id'
order by io_type asc, ct_num asc, ct_id asc ";
$result = sql_query($sql);
$str = '';
for($i=0; $row=sql_fetch_array($result); $i++) {
if($i == 0)
$str .= '<ul>'.PHP_EOL;
$str .= '<li>'.$row['ct_option'].'</li>'.PHP_EOL;
$str .= '<li>'.$row['ct_option'].'&nbsp;&nbsp;'.$row['ct_qty'].'개</li>'.PHP_EOL;
}
if($i > 0)

View File

@ -33,6 +33,7 @@ if(!mysql_num_rows($result))
<input type="hidden" name="it_name" value="<?php echo $row2['it_name']; ?>">
<input type="hidden" name="total_price" value="">
<input type="hidden" name="sw_direct">
<input type="hidden" name="ct_order" value="<?php echo $idx; ?>">
<?php
$option_1 = get_item_options($it['it_id'], $it['it_option_subject']);
if($option_1) {

View File

@ -55,7 +55,7 @@ $sql = " select a.ct_id,
from {$g4['shop_cart_table']} a left join {$g4['shop_item_table']} b on ( a.it_id = b.it_id )
where a.uq_id = '$s_uq_id'
and a.ct_num = '0'
order by a.ct_id ";
order by a.ct_order, a.ct_id ";
$result = sql_query($sql);
$good_info = '';
@ -67,7 +67,8 @@ for ($i=0; $row=mysql_fetch_array($result); $i++)
SUM(ct_point * ct_qty) as point,
SUM(ct_qty) as qty
from {$g4['shop_cart_table']}
where it_id = '{$row['it_id']}' ";
where it_id = '{$row['it_id']}'
and uq_id = '$s_uq_id' ";
$sum = sql_fetch($sql);
if (!$goods)

View File

@ -211,24 +211,17 @@ else if ($act == "optionmod") // 장바구니에서 옵션변경
}
//--------------------------------------------------------
// 바로구매에 있던 장바구니 자료를 지운다.
$result = sql_query(" delete from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' and ct_direct = 1 ", false);
if (!$result) {
// 삭제중 에러가 발생했다면 필드가 없다는 것이므로 바로구매 필드를 생성한다.
sql_query(" ALTER TABLE `{$g4['shop_cart_table']}` ADD `ct_direct` TINYINT NOT NULL ");
}
// 포인트 사용하지 않는다면
if (!$config['cf_use_point']) { $_POST['it_point'] = 0; }
// 장바구니에 Insert
$comma = '';
$sql = " INSERT INTO {$g4['shop_cart_table']}
( uq_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_num, io_id, io_type, io_price, ct_time, ct_ip, ct_direct )
( uq_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_num, io_id, io_type, io_price, ct_time, ct_ip, ct_direct, ct_order )
VALUES ";
for($i=0; $i<$option_count; $i++) {
$sql .= $comma."( '$tmp_uq_id', '{$_POST['it_id']}', '{$_POST['it_name']}', '쇼핑', '{$_POST['it_price']}', '{$_POST['it_point']}', '0', '0', '{$_POST['io_value'][$i]}', '{$_POST['ct_qty'][$i]}', '$i', '{$_POST['io_id'][$i]}', '{$_POST['io_type'][$i]}', '{$_POST['io_price'][$i]}', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$sw_direct' )";
$sql .= $comma."( '$tmp_uq_id', '{$_POST['it_id']}', '{$_POST['it_name']}', '쇼핑', '{$_POST['it_price']}', '{$_POST['it_point']}', '0', '0', '{$_POST['io_value'][$i]}', '{$_POST['ct_qty'][$i]}', '$i', '{$_POST['io_id'][$i]}', '{$_POST['io_type'][$i]}', '{$_POST['io_price'][$i]}', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$sw_direct', '{$_POST['ct_order']}' )";
$comma = ' , ';
}

View File

@ -28,14 +28,12 @@ $ft_a_st = 'display:block;padding:30px 0;background:#484848;color:#fff;text-alig
<col>
<col style="width:100px">
<col style="width:70px">
<col style="width:50px">
</colgroup>
<thead>
<tr>
<th scope="col" style="<?php echo $th_st; ?>">품명</th>
<th scope="col" style="<?php echo $th_st; ?>">옵션</th>
<th scope="col" style="<?php echo $th_st; ?>">상태</th>
<th scope="col" style="<?php echo $th_st; ?>">수량</th>
</tr>
<thead>
<tbody>
@ -44,7 +42,6 @@ $ft_a_st = 'display:block;padding:30px 0;background:#484848;color:#fff;text-alig
<td style="<?php echo $td_st; ?>"><a href="<?php echo G4_SHOP_URL; ?>/item.php?it_id=<?php echo $cart_list[$i]['it_id']; ?>" target="_blank" style="text-decoration:none"><?php echo $cart_list[$i]['it_name']; ?></a></td>
<td style="<?php echo $td_st; ?>;text-align:center"><?php echo $cart_list[$i]['it_opt']; ?></td>
<td style="<?php echo $td_st; ?>;text-align:center"><?php echo $cart_list[$i]['ct_status']; ?></td>
<td style="<?php echo $td_st; ?>;text-align:center"><?php echo $cart_list[$i]['ct_qty']; ?></td>
</tr>
<?php } // end for ?>
</tbody>

View File

@ -48,10 +48,6 @@ $ft_a_st = 'display:block;padding:30px 0;background:#484848;color:#fff;text-alig
<th scope="row" style="<?php echo $th_st; ?>">판매가격</th>
<td style="<?php echo $td_st; ?>"><?php echo display_price($list[$i]['ct_price']); ?></td>
</tr>
<tr>
<th scope="row" style="<?php echo $th_st; ?>">수량</th>
<td style="<?php echo $td_st; ?>"><?php echo number_format($list[$i]['ct_qty']); ?>개</td>
</tr>
<tr>
<th scope="row" style="<?php echo $th_st; ?>">소계</th>
<td style="<?php echo $td_st; ?>"><?php echo display_price($list[$i]['stotal_amount']); ?></td>

View File

@ -48,10 +48,6 @@ $ft_a_st = 'display:block;padding:30px 0;background:#484848;color:#fff;text-alig
<th scope="row" style="<?php echo $th_st; ?>">판매가격</th>
<td style="<?php echo $td_st; ?>"><?php echo display_price($list[$i]['ct_price']); ?></td>
</tr>
<tr>
<th scope="row" style="<?php echo $th_st; ?>">수량</th>
<td style="<?php echo $td_st; ?>"><?php echo number_format($list[$i]['ct_qty']); ?>개</td>
</tr>
<tr>
<th scope="row" style="<?php echo $th_st; ?>">소계</th>
<td style="<?php echo $td_st; ?>"><?php echo display_price($list[$i]['stotal_amount']); ?></td>

View File

@ -47,10 +47,6 @@ $ft_a_st = 'display:block;padding:30px 0;background:#484848;color:#fff;text-alig
<th scope="row" style="<?php echo $th_st; ?>">판매가격</th>
<td style="<?php echo $td_st; ?>"><?php echo display_price($list[$i]['ct_price']); ?></td>
</tr>
<tr>
<th scope="row" style="<?php echo $th_st; ?>">수량</th>
<td style="<?php echo $td_st; ?>"><?php echo number_format($list[$i]['ct_qty']); ?>개</td>
</tr>
</tbody>
</table>

View File

@ -20,22 +20,26 @@ if (get_cart_count($tmp_uq_id) == 0)// 장바구니에 담기
$error = "";
// 장바구니 상품 재고 검사
// 1.03.07 : and a.it_id = b.it_id : where 조건문에 이 부분 추가
$sql = " select a.it_id,
a.ct_qty,
a.it_name
from {$g4['shop_cart_table']} a,
{$g4['shop_item_table']} b
where a.uq_id = '$tmp_uq_id'
and a.it_id = b.it_id ";
$sql = " select it_id,
ct_qty,
it_name,
io_id,
io_type,
ct_option
from {$g4['shop_cart_table']}
where uq_id = '$tmp_uq_id' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
// 상품에 대한 현재고수량
$it_stock_qty = (int)get_it_stock_qty($row['it_id']);
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['it_name']} 의 재고수량이 부족합니다. 현재고수량 : $it_stock_qty\\n\\n";
$error .= "{$row['ct_option']} 의 재고수량이 부족합니다. 현재고수량 : $it_stock_qty\\n\\n";
}
if ($error != "")
@ -50,7 +54,8 @@ $i_temp_point = (int)$_POST['od_temp_point'];
// 주문금액이 상이함
$sql = " select SUM(ct_price * ct_qty) as od_amount from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' ";
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as od_amount
from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' ";
$row = sql_fetch($sql);
if ((int)$row['od_amount'] !== $i_amount) {
die("Error.");

View File

@ -10,35 +10,37 @@ $ttotal_point = 0;
// 메일보내기
//------------------------------------------------------------------------------
// Loop 배열 자료를 만들고
$sql = " select b.it_sell_email,
a.it_id,
$sql = " select a.it_id,
a.it_name,
b.it_origin,
a.it_opt1,
a.it_opt2,
a.it_opt3,
a.it_opt4,
a.it_opt5,
a.it_opt6,
a.ct_qty,
a.ct_price,
a.ct_point
from {$g4['shop_cart_table']} a, {$g4['shop_item_table']} b
a.ct_point,
b.it_sell_email,
b.it_origin
from {$g4['shop_cart_table']} a left join {$g4['shop_item_table']} b on ( a.it_id = b.it_id )
where a.uq_id = '$tmp_uq_id'
and a.it_id = b.it_id ";
and a.ct_num = '0' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
// 합계금액 계산
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
SUM(ct_point * ct_qty) as point,
SUM(ct_qty) as qty
from {$g4['shop_cart_table']}
where it_id = '{$row['it_id']}'
and uq_id = '$tmp_uq_id' ";
$sum = sql_fetch($sql);
$list[$i]['g_dir'] = G4_URL;
$list[$i]['it_id'] = $row['it_id'];
$list[$i]['it_simg'] = get_it_image($row['it_id'], $default['de_simg_width'], $default['de_simg_height']);
$list[$i]['it_name'] = $row['it_name'];
$list[$i]['it_origin'] = $row['it_origin'];
$list[$i]['it_opt'] = print_item_options($row['it_id'], $row['it_opt1'], $row['it_opt2'], $row['it_opt3'], $row['it_opt4'], $row['it_opt5'], $row['it_opt6']);
$list[$i]['ct_qty'] = $row['ct_qty'];
$list[$i]['it_opt'] = print_item_options($row['it_id'], $tmp_uq_id);
$list[$i]['ct_price'] = $row['ct_price'];
$list[$i]['stotal_amount'] = $row['ct_price'] * $row['ct_qty'];
$list[$i]['stotal_point'] = $row['ct_point'] * $row['ct_qty'];
$list[$i]['stotal_amount'] = $sum['price'];
$list[$i]['stotal_point'] = $sum['point'];
$ttotal_amount += $list[$i]['stotal_amount'];
$ttotal_point += $list[$i]['stotal_point'];

View File

@ -36,17 +36,10 @@ mailer($config['cf_title'], $admin['mb_email'], $od_email, $subject, $content, 1
$sql = " select b.it_sell_email,
a.it_id,
a.it_name,
a.it_opt1,
a.it_opt2,
a.it_opt3,
a.it_opt4,
a.it_opt5,
a.it_opt6,
a.ct_qty
from {$g4['shop_cart_table']} a, {$g4['shop_item_table']} b
a.it_name
from {$g4['shop_cart_table']} a left join {$g4['shop_item_table']} b on ( a.it_id = b.it_id )
where a.uq_id = '$tmp_uq_id'
and a.it_id = b.it_id
and a.ct_num = '0'
and b.it_sell_email <> '' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
@ -56,8 +49,7 @@ for ($i=0; $row=sql_fetch_array($result); $i++)
$list['it_id'] = $row['it_id'];
$list['it_simg'] = get_it_image($row['it_id'], $default['de_simg_width'], $default['de_simg_height']);
$list['it_name'] = $row['it_name'];
$list['it_opt'] = print_item_options($row['it_id'], $row['it_opt1'], $row['it_opt2'], $row['it_opt3'], $row['it_opt4'], $row['it_opt5'], $row['it_opt6']);
$list['ct_qty'] = $row['ct_qty'];
$list['it_opt'] = print_item_options($row['it_id'], $tmp_uq_id);
$subject = $config['cf_title'].' - 주문 알림 메일 (주문자 '.$od_name.'님)';
ob_start();