채택완료

자동배송 완료 넘기기

2021-04-22 (목) 12:58:16 2,172

https://sir.kr/yc5_tip/1247#c_1847 
글참고 하여 

Copy
//  자동 배송완료 만들기
    $beforedays = date("Y-m-d H:i:s", ( time() - (86400 * (int)$default['de_point_days']) ) ); // 86400초는 하루
    $sql22 = " select * from {$g5['g5_shop_cart_table']} where ct_status = '배송' and ct_time <= '$beforedays' ";

$result22 = sql_query($sql22);
    for ($i=0; $row22=sql_fetch_array($result22); $i++) {

/*
echo "update {$g5['g5_shop_cart_table']} set ct_status = '완료' where ct_id = '{$row22['ct_id']}' ";
echo "<br>";
echo "update {$g5['g5_shop_order_table']} set od_status = '완료' where  od_id = '{$row22['od_id']}' ";
echo "<br>";echo "<br>";
*/
sql_query("update {$g5['g5_shop_cart_table']} set ct_status = '완료' where ct_id = '{$row22['ct_id']}' ");  // 오더테이블
sql_query("update {$g5['g5_shop_order_table']} set od_status = '완료' where od_id = '{$row22['od_id']}' ");  // 카트테이블
}
 

적용하려고합니다. 
어느파일에 위 코드를 넣어야할까요 ?

그리고 혹시 배송일로부터 7일 을 적용하고싶으면.
ct_time 을 - > od_invoice_time 이렇게 수정하면되지않을까요 ?

|

답변 2개 / 댓글 8개

채택된 답변
+20 포인트
2021-04-22 (목) 13:35:13

cron에 넣는 것이 가장 좋을 듯합니다.

다음으로는

배송 상태를 확인하는 페이지 윗부분에 넣으면 되지 않을까요?

답변에 대한 댓글 7개

크론 으로 설정하시라는 말씀이신가용 ??
그리고 혹시 배송일로부터 7일 을 적용하고싶으면.
ct_time 을 - > od_invoice_time 이부분이 맞을까요?ㅠㅠ
od_invoice_time이 맞을 것 같습니다.

영카트는 주문과 배송이 분리 되어 있지 않아
주문리스트에서 배송 업무를 보게 되어 있어 좀 불편한 점은 있죠.
언젠가는 배송과 주문이 분리가 되겠죠.
그렇다면 위에 저코드를 orderlist.php 상단에 작성하면 될까요 ?
친절하게 답변해주셔서 감사합니다.
adm/shop_admin/orderlist.php
가 적당할지 어떨지는
쇼핑몰을 운영하면서 살펴 봐야 할 문제라고 생각합니다.
[code]
// 자동 배송완료 만들기
$beforedays = date("Y-m-d H:i:s", ( time() - (86400 * (int)$default['de_point_days']) ) ); // 86400초는 하루
$sql22 = " select * from {$g5['g5_shop_cart_table']} A inner join {$g5['g5_shop_order_table']} B using( od_id)
set A.ct_status = '완료', B.od_status = '완료' where A.ct_time < now() - interval 7 day and A.ct_status='배송' and ct_time <= '$beforedays' ";
$result22 = sql_query($sql22);
for ($i=0; $row22=sql_fetch_array($result22); $i++) {
/*
echo "update {$g5['g5_shop_cart_table']} set ct_status = '완료' where ct_id = '{$row22['ct_id']}' ";
echo "<br>";
echo "update {$g5['g5_shop_order_table']} set od_status = '완료' where od_id = '{$row22['od_id']}' ";
echo "<br>";echo "<br>";
*/
sql_query("update {$g5['g5_shop_cart_table']} set ct_status = '완료' where ct_id = '{$row22['ct_id']}' "); // 오더테이블
sql_query("update {$g5['g5_shop_order_table']} set od_status = '완료' where od_id = '{$row22['od_id']}' "); // 카트테이블
}

[/code]
이렇게맞을까요 ?
제가 적은 update 구문은 loop가 필요 없습니다.
update 구문은 loop가 필요 없다면
죄송하지만 어떤 식으로 작성하면되는지 작성해주실수있으실까요??
정말 죄송합니다 ㅠㅠ
2021-04-23 (금) 00:13:29
sql_query("update  {$g5['g5_shop_order_table']} A inner join {$g5['g5_shop_cart_table']} B on A.od_id=B.od_id and B.ct_status='배송'
set B.ct_status = '완료', A.od_status = '완료'
where A.od_invoice_time< now() - interval 7 day ");

정확한 것은 한번 테스트해 보시기 바랍니다.

답변에 대한 댓글 1개

// 자동 배송완료 만들기
$beforedays = date("Y-m-d H:i:s", ( time() - (86400 * (int)$default['de_point_days']) ) ); // 86400초는 하루
$sql22 = " select * from {$g5['g5_shop_cart_table']} where ct_status = '배송' and ct_time <= '$beforedays' ";
$result22 = sql_query($sql22);
for ($i=0; $row22=sql_fetch_array($result22); $i++) {

sql_query("update {$g5['g5_shop_order_table']} A inner join {$g5['g5_shop_cart_table']} B on A.od_id=B.od_id and B.ct_status='배송'
set B.ct_status = '완료', A.od_status = '완료'
where A.od_invoice_time< now() - interval 7 day ");
}

답변을 작성하려면 로그인이 필요합니다.