세

상품별 특정기간에 정해진 금액으로 노출, 결제하기

· 2025-07-24 (목) 14:46:10 · 1851

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로 찾길 권장

 

 

나중에 다시 작업할때 찾기용으로 기록해둡니다.

|
댓글을 작성하시려면 로그인이 필요합니다.
+
제목 글쓴이 날짜 조회
25-09-03 조회 1,697
25-08-26 조회 2,021
25-08-18 조회 2,080
25-08-16 조회 1,763
25-08-07 조회 1,882
25-07-31 조회 1,792
25-07-28 조회 1,904
25-07-24 조회 1,852
25-07-21 조회 1,828
25-07-14 조회 1,654
25-07-08 조회 1,894
25-07-01 조회 1,863
25-06-24 조회 1,873
25-06-05 조회 1,743
25-06-04 조회 1,456
25-04-08 조회 2,025
25-04-08 조회 1,679
25-03-24 조회 1,695
25-01-20 조회 2,233
24-12-31 조회 2,219
24-12-28 조회 1,677
24-10-24 조회 2,469
24-10-22 조회 1,879
24-10-21 조회 1,995
24-09-26 조회 3,628
24-09-18 조회 2,653
24-08-26 조회 4,244
24-08-23 조회 1,871
24-07-22 조회 4,683
24-07-18 조회 2,468