테스트 사이트 - 개발 중인 베타 버전입니다

상품 주문시 추가내용 및 파일을 받을 수 있게 하는 팁

· 11년 전 · 15771 · 52
이 기능은 상품 주문시에 메모와 파일을 첨부한 채로 주문을 할 수 있는 기능입니다.
예를 들어 인쇄업체에서 인쇄내용을 첨부한채로 주문시, 별도의 게시판을 필요로 없이 할 수 있게끔 하는 기능이라고 보시면됩니다.
(영카트4에서는 옵션을 입력받게끔 수정해서 사용하던 것과 비슷한 팁입니다)


고급이지 못한 실력으로 차례차례 밟아간 터라,
내용이 매끄럽지 못할것입니다.

내용이 많으니 잘 따라오세요~
참고로 영카트 본체파일을 건드려야 하니, 꼭 백업해두세요~



먼저, 필드를 두개 추가해주셔야 합니다.
/adm/config_form.php
파일에 넣었습니다만, 필드추가를 위한 부분이니 아무데나 넣고 웹에서 실행시켜줍니다.

// 주문시 추가내용/파일 입력위한 추가
sql_query(" ALTER TABLE `{$g5['g5_shop_cart_table']}`
ADD `ct_msg` varchar(255) NOT NULL DEFAULT '' AFTER `ct_select`,
ADD `ct_file` varchar(255) NOT NULL DEFAULT '' AFTER `ct_msg` ", true);



이제 mysql 은 준비되었으니,
주문하는 페이지부터 시작입니다.

/skin/shop/basic/item.form.skin.php

약 8번째줄
<form name="fitem" method="post" action="<?php echo $action_url; ?>" onsubmit="return fitem_submit(this);">
이부분을
<form name="fitem" method="post" enctype="MULTIPART/FORM-DATA" action="<?php echo $action_url; ?>" onsubmit="return fitem_submit(this);">

바꿔줍니다.

약 340번줄 즈음에
<!-- 다른 상품 보기 시작 { -->
.....
<!-- } 다른 상품 보기 끝 -->

다음에 아래를 추가해줍니다.
<!-- 별도 작업 요청사항 시작 { -->
<div id="sit_spinput">
<textarea name="work_msg"></textarea>
<input type="file" name="work_file">
</div>
<!-- } 별도 작업 요청사항 끝 -->

디자인은 알아서 잡으시구요~ ㅋ




눈에 보이는 부분이 끝났습니다.

/shop/cartupdate.php
에서 처리할 부분은 실제로 내용을 입력, 제거시 첨부파일을 삭제하는 내용입니다.


약 50번째줄
else if ($act == "alldelete") // 모두 삭제이면
이부분의 바로다음,
$sql = " delete from {$g5['g5_shop_cart_table']}
이부분의 바로 전에,

//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where od_id = '$tmp_cart_id' ";
$dwresult = sql_query($sqld);
for ($i=0; $row=mysql_fetch_array($dwresult); $i++)
@unlink(G5_DATA_PATH."/odfile/".$row[ct_file]);

추가해줍니다.


약 60번째줄
else if ($act == "seldelete") // 선택삭제
이부분 다음에
$it_id = $_POST['it_id'][$i];
의 바로 아래에

//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and od_id = '$tmp_cart_id' ";
$dw = sql_fetch($sqld);
@unlink(G5_DATA_PATH."/odfile/".$dw[ct_file]);

추가해줍니다.



내용을 db에 입력하고 파일을 업로드할차례입니다.
같은 파일에
약 206번째줄

$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select )
VALUES ";

이부분을

$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_msg, ct_file )
VALUES ";

보면 끝에 두 필드가 추가되있습니다.


268번째줄정도에

// 배송비결제
....
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
$ct_send_cost = 1; // 착불

이부분이 있습니다. 바로 다음에 추가해줍니다.

//작업용 파일 업로드 추가
if($_FILES['work_file']['name']){
$ct_file_dir = G5_DATA_PATH.'/odfile';
if(!is_dir($ct_file_dir)) {
@mkdir($ct_file_dir, G5_DIR_PERMISSION);
@chmod($ct_file_dir, G5_DIR_PERMISSION);
}

$f_pt = "/[#\&\+\-%@=\/\\:;,'\"\^`~\|\!\?\*\$#<>\(\)\[\]\{\}]/";

$work_file = $_FILES['work_file']['name'];
$work_file = preg_replace("/\s+/", "", $work_file);
$work_file = preg_replace( $f_pt, "", $work_file);

$work_file = preg_replace_callback(
"/[가-힣]+/",
create_function('$matches', 'return base64_encode($matches[0]);'),
$work_file);

$work_file = preg_replace( $f_pt, "", $work_file );

$work_file_check=strtolower(array_pop(explode('.',$work_file)));
$deny_file = array("php","php3","exe","cgi","phtml","html","htm","pl","asp","jsp","inc","dll");

if(in_array($work_file_check,$deny_file))
alert('$filename 파일은 업로드할수 없는 확장자의 파일입니다.');

$work_file = $tmp_cart_id."_".$work_file;
upload_file($_FILES['work_file']['tmp_name'], $work_file, $ct_file_dir);
}

그 바로 아래에
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )";

이부부을
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select', '".addslashes($work_msg)."', '$work_file' )";

와 같이 변경해줍니다.


cartupdate.php 부분이 끝났습니다.



이제 입력된 내용을 관리자가 확인해야겠습니다.

저는
/adm/shop_admin/orderform.php
파일에서만 내용을 확인하면 되겠다고 판단했습니다.

약 164번째줄에
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price
이 쿼리문을
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price, ct_msg, ct_file
와 같이 바꿔줍니다.

약 241번째줄이 </tr>입니다. 한 주문상품의 for 문중 테이블 라인이 끝나는 부분이지요.
이 바로 다음에 추가해줍니다.

<?php
if($opt['ct_msg'] || $opt['ct_file']) {
?>
<tr>
<th>추가작업내용</th>
<td colspan="8" class="td_mngsmall"><?php echo stripslashes($opt['ct_msg']); ?></td>
<th>첨부파일</th>
<td colspan="2" class="td_mngsmall"><a href="<?php echo G5_DATA_URL."/odfile/".$opt['ct_file']?>">다운받기</a></td>
</tr>
<?php
}
?>

이 내용으로 인해 주문이 들어왔을때 메세지 혹은 파일이 있을경우 한줄이 추가되어 확인가능해집니다.


이제 주문서를 삭제했을때를 위해 수정합니다.
yc5는 리스트에서 "주문"으로 검색시 해당되는 부분만 삭제버튼이 나타나게 되어있습니다.

때문에 /adm/shop_admin/orderlistdelete.php 파일만 수정합니다.


약 14번째줄 if (!$od) continue; 다음에

//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where od_id = '$od_id' ";
$dwresult = sql_query($sqld);
for ($i=0; $row=mysql_fetch_array($dwresult); $i++)
@unlink(G5_DATA_PATH."/odfile/".$row[ct_file]);

위 내용을 추가해줍니다.





이정도 까지 하면 주문할때 문제가 없고,
관리자가 확인할 때 문제가 없으며,
사용자던, 관리자던 주문서를 삭제했을때는 서버에 쓰레기 파일이 남지 않을것입니다.



관리자가 확인하고 삭제시 처리하는 부분을 응용해서,
주문확인에서도 적용시킬 수 있겠지요.

혹은 주문확인에서 본 내용만을 수정하게도 가능할것입니다.



내용이 복잡해서 미루다가 이제서야 올립니다.
아직 오픈할정도로 테스트는 이루어지지않았습니다.
버그나 오작동 할 경우 알려주세요 ^^;

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 52개

버전이 많이 바뀐데다 간단하게 적용 가능한 부분이 아니어서...
포스팅을 삭제해야 할지 고민입니다. ㅠㅠ
잘 되신다니 다행입니다~
7년 전
저는 5.3 버전에서 적용해 보려고 아래와 같이 한 부분에서
/adm/shop_admin/orderform.php

A) 약 156번째줄에

// 상품의 옵션정보
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price

이 쿼리문을
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price, ct_msg, ct_file​

와 같이 바꿔주었더니

관리자 주문내역-> 보기 눌러서 보면 상품이 사라졌습니다.
그래서 확인해 본결과 위에서마지막에 있는 "ct_file​" 부분을 삭제 하니 나타 나더군요
"ct_file​" 부분만 추가 하면 상품이 사라지더군요
어떻게 하면 해결이 될까요?
해당 필드가 있는지 점검해보시는것이 가장 맞는것같습니다. 리스트화를 시킬때 where 문이나 for문 안에서 if($row[cf_title]){ 과같은게 있지 않는 바에는 원인은 필드가 없는것밖에 찾지 못하겠네요. 화이팅 하시길 바랍니다~
좋은팁 감사합니다.
갑사합니다
6년 전
죄송한데 적용다하고나니까 오류인지 결제창 페이지로 안넘어가네요 ㅠㅠ
지금버전이랑 조금 틀려진부분이 있는걸까요?
youngcart5.3.2.3 그대로 복사안하고 추가하면서 하니 잘됩니다...감사합니다
댓글 모두 참고해서 해봤는데...
cartupdate.php 파일의

$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_msg, ct_file )
VALUES ";

이부분부터 갑자기 장바구니가 비었다고합니다..

즉, ct_msg, ct_file을 추가할때부터 장바구니가 비었다고 나옵니다

그래서 그 아래에 댓글에 말씀해주신것처럼

$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$remote_addr', '$ct_send_cost', '$sw_direct', '$ct_select', '$ct_select_time', '$ct_msg', '$ct_file' )";

이렇게 끝에 '$ct_msg', '$ct_file'을 추가해도 장바구니가 비었다고 나오는건 똑같습니다...
이부분부터가 문제인거같은데 이문제 해결하신분 계신가요?

물론 바로구매를 눌렀을때 입니다.

[http://sir.kr/data/editor/1903/577e1055122c8216286fad5ca536cf35_1551851467_4836.jpg]
잘됩니다...윗분들이 다 굉장한 분들..감사합니다
대단히 잘되네요....감사합니다

게시글 목록

번호 제목
2400
2394
2363
2362
2351
2350
2348
2347
2336
2326
2324
2323
2318
2306
2305
2299
2295
2293
2283
2279
2266
2254
2248
2232
2231
2204
2184
2183
2181
2179