2026, 새로운 도약을 시작합니다.

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

· 5개월 전 · 513

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

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

|

댓글 작성

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

로그인하기

영카트5 팁자료실

번호 제목 글쓴이 날짜 조회
441 3주 전 조회 239
440 1개월 전 조회 189
439 1개월 전 조회 291
438 1개월 전 조회 459
437 2개월 전 조회 657
436 2개월 전 조회 270
435 2개월 전 조회 382
434 3개월 전 조회 536
433 3개월 전 조회 368
432 3개월 전 조회 338
431 3개월 전 조회 443
430 3개월 전 조회 406
429 3개월 전 조회 359
428 3개월 전 조회 367
427 4개월 전 조회 509
426 4개월 전 조회 536
425 4개월 전 조회 353
424 4개월 전 조회 628
423 4개월 전 조회 599
422 4개월 전 조회 520
421 5개월 전 조회 572
420 5개월 전 조회 489
419 5개월 전 조회 571
418 5개월 전 조회 514
417 5개월 전 조회 622
416 5개월 전 조회 428
415 6개월 전 조회 564
414 6개월 전 조회 567
413 6개월 전 조회 661
412 7개월 전 조회 551
🐛 버그신고