상품별 특정기간에 정해진 금액으로 노출, 결제하기 정보
상품별 특정기간에 정해진 금액으로 노출, 결제하기본문
g5_shop_item 테이블에 it_event_stime(datetime), it_event_etime(datetime), it_event_price(int)가 있다고 가정할 때
1. /lib/shop.lib.php
get_price 함수를 아래와 같이 변경
=============================================
function get_price($it)
{
global $member;
if ($it['it_tel_inq']) return '전화문의';
$price = (int)$it['it_price'];
// 이벤트 가격 처리
if (!empty($it['it_event_stime']) && !empty($it['it_event_etime'])) {
$now = date('Y-m-d H:i:s');
if ($now >= $it['it_event_stime'] && $now <= $it['it_event_etime']) {
// 이벤트 기간 중이면 이벤트 가격 반환
return (int)$it['it_event_price'];
}
}
return $price;
}
=============================================
2. /lib/shop.lib.php
before_check_cart_price 함수를 찾아서 함수내에 $it = get_shop_item($it_id, $is_item_cache); 바로 아래 추가
=============================================
// 이벤트 가격 적용 여부 확인
$event_price = (int)$it['it_price'];
$now = G5_TIME_YMDHIS;
if (!empty($it['it_event_stime']) && !empty($it['it_event_etime'])) {
if ($now >= $it['it_event_stime'] && $now <= $it['it_event_etime']) {
if ((int)$it['it_event_price'] > 0) {
$event_price = (int)$it['it_event_price'];
}
}
}
=============================================
조금 밑에 기존
=============================================
if( $it['it_price'] !== $row['ct_price'] ){
// 장바구니 테이블 상품 가격과 상품 테이블의 상품 가격이 다를경우
$update_querys['ct_price'] = $it['it_price'];
}
=============================================
이 코드를 아래로 변경
=============================================
if( $event_price !== (int)$row['ct_price'] ){
$update_querys['ct_price'] = $event_price;
}
=============================================
2번의 경우는 before_check_cart_price 함수가 있을 경우이고 없을경우 /shop/cartupdate.php에서 $it = get_shop_item($it_id, false); 바로아래에 추가
=============================================
// 이벤트 기간 가격 적용
$now = G5_TIME_YMDHIS;
$use_event_price = false;
$event_price = (int)$it['it_price']; // 기본 가격
if (!empty($it['it_event_stime']) && !empty($it['it_event_etime'])) {
if ($now >= $it['it_event_stime'] && $now <= $it['it_event_etime']) {
if ((int)$it['it_event_price'] > 0) {
$use_event_price = true;
$event_price = (int)$it['it_event_price'];
}
}
}
=============================================
그리고 sql 추가부분
=============================================
$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' )";
=============================================
를 아래로 변경
=============================================
$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']}', '쇼핑', '{$event_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_price부분에 $event_price로 변경(보통 '쇼핑', 이후에 들어가기 때문에 Ctrl+F로 찾길 권장
나중에 다시 작업할때 찾기용으로 기록해둡니다.
0
댓글 0개