상품 구매 완료시 회원 레벨 올리기 정보
상품 구매 완료시 회원 레벨 올리기본문
상품 구매 완료시에 회원 레벨을 특정 레벨로 상향시키는 방법입니다.
영카트 기본 기능에 있는 적립금 지급 부분에 한 줄 끼워 넣었습니다.
적립금이 0 인 상품도 레벨 상향 부분은 작동할 겁니다.
수정 파일 lib/shop.lib.php
아래 함수에서 마지막 부분 쿼리가 한 줄 추가되었습니다.
sql_query("update {$g5['member_table']} set mb_level = '5' where mb_id = '{$od_row['mb_id']}' ");
mb_level = '5' 부분을 원하는 레벨로 수정하시면 됩니다.
function save_order_point($ct_status="완료")
{
global $g5, $default;
$beforedays = date("Y-m-d H:i:s", ( time() - (86400 * (int)$default['de_point_days']) ) ); // 86400초는 하루
$sql = " select * from {$g5['g5_shop_cart_table']} where ct_status = '$ct_status' and ct_point_use = '0' and ct_time <= '$beforedays' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
// 회원 ID 를 얻는다.
$od_row = sql_fetch("select od_id, mb_id from {$g5['g5_shop_order_table']} where od_id = '{$row['od_id']}' ");
if ($od_row['mb_id'] && $row['ct_point'] > 0) { // 회원이면서 포인트가 0보다 크다면
$po_point = $row['ct_point'] * $row['ct_qty'];
$po_content = "주문번호 {$od_row['od_id']} ({$row['ct_id']}) 배송완료";
insert_point($od_row['mb_id'], $po_point, $po_content, "@delivery", $od_row['mb_id'], "{$od_row['od_id']},{$row['ct_id']}");
}
sql_query("update {$g5['g5_shop_cart_table']} set ct_point_use = '1' where ct_id = '{$row['ct_id']}' ");
sql_query("update {$g5['member_table']} set mb_level = '5' where mb_id = '{$od_row['mb_id']}' ");
}
}
적립금 지급 시점과 동시에 레벨이 상승하게 되며 즉시 바뀌게 하고 싶으면
관리자페이지 > 쇼핑몰관리 > 쇼핑몰 설정 > 주문완료포인트 지급 시점을 0으로 수정
기본값은 7일로 되어 있을 겁니다.
테스트하실 때 관리자로 하진 마세요.
예외 처리 안 해놔서 관리자도 레벨이 강제로 변경됩니다.
영카트 기본 기능에 있는 적립금 지급 부분에 한 줄 끼워 넣었습니다.
적립금이 0 인 상품도 레벨 상향 부분은 작동할 겁니다.
수정 파일 lib/shop.lib.php
아래 함수에서 마지막 부분 쿼리가 한 줄 추가되었습니다.
sql_query("update {$g5['member_table']} set mb_level = '5' where mb_id = '{$od_row['mb_id']}' ");
mb_level = '5' 부분을 원하는 레벨로 수정하시면 됩니다.
function save_order_point($ct_status="완료")
{
global $g5, $default;
$beforedays = date("Y-m-d H:i:s", ( time() - (86400 * (int)$default['de_point_days']) ) ); // 86400초는 하루
$sql = " select * from {$g5['g5_shop_cart_table']} where ct_status = '$ct_status' and ct_point_use = '0' and ct_time <= '$beforedays' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
// 회원 ID 를 얻는다.
$od_row = sql_fetch("select od_id, mb_id from {$g5['g5_shop_order_table']} where od_id = '{$row['od_id']}' ");
if ($od_row['mb_id'] && $row['ct_point'] > 0) { // 회원이면서 포인트가 0보다 크다면
$po_point = $row['ct_point'] * $row['ct_qty'];
$po_content = "주문번호 {$od_row['od_id']} ({$row['ct_id']}) 배송완료";
insert_point($od_row['mb_id'], $po_point, $po_content, "@delivery", $od_row['mb_id'], "{$od_row['od_id']},{$row['ct_id']}");
}
sql_query("update {$g5['g5_shop_cart_table']} set ct_point_use = '1' where ct_id = '{$row['ct_id']}' ");
sql_query("update {$g5['member_table']} set mb_level = '5' where mb_id = '{$od_row['mb_id']}' ");
}
}
적립금 지급 시점과 동시에 레벨이 상승하게 되며 즉시 바뀌게 하고 싶으면
관리자페이지 > 쇼핑몰관리 > 쇼핑몰 설정 > 주문완료포인트 지급 시점을 0으로 수정
기본값은 7일로 되어 있을 겁니다.
테스트하실 때 관리자로 하진 마세요.
예외 처리 안 해놔서 관리자도 레벨이 강제로 변경됩니다.
추천
5
5
댓글 4개
좋은 자료 감사합니다. ^^
감사합니다
좋은 자료 감사합니다.
좋은 자료 감사합니다~ 한가지 질문있습니다. 상품별로 등급을 다르게 주고싶은데
지금 코드는 구매시 적립금 지급과 함께 등급을 주는건데 상품마다 다른 등급을 줄 수 있을까요?
지금 코드는 구매시 적립금 지급과 함께 등급을 주는건데 상품마다 다른 등급을 줄 수 있을까요?