[Y5] 장바구니 담긴후 가격이 변경된 경우 > 기술자료 | 해피정닷컴

[Y5] 장바구니 담긴후 가격이 변경된 경우 > 기술자료

본문 바로가기

사이트 내 전체검색

[Y5] 장바구니 담긴후 가격이 변경된 경우 > 기술자료

영카트 [Y5] 장바구니 담긴후 가격이 변경된 경우

페이지 정보


본문

장바구니에 담긴후 상품 가격이 변경되었습니다.
이후 고객이 장바구니에 있는 상품을 구매를 진행할때 가격이 변경되도록 하는 방법입니다.
영카트 5.xx 이전 버전에는 아래와 같이 추가합니다.


1. lib / shop.data.lib.php  파일이 존재하는 확인
get_shop_item  함수가 있는지 확인

없으면  lib / shop.lib.php  끝에  아래 함수 추가

// lib/shop.data.lib.php 에 포함된 내용
if(!function_exists("get_shop_item")) {
function get_shop_item($it_id, $is_cache=false, $add_query=''){
    
    global $g5, $g5_object;

    $add_query_key = $add_query ? 'shop_'.md5($add_query) : '';

    $item = $is_cache ? $g5_object->get('shop', $it_id, $add_query_key) : null;

    if( !$item ){
        $sql = " select * from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' $add_query ";
        $item = sql_fetch($sql);

        $g5_object->set('shop', $it_id, $item, $add_query_key);
    }
    
    if( isset($item['it_basic']) ) {
        $item['it_basic'] = conv_content($item['it_basic'], 1);
    }

    if( ! isset($item['it_id']) ){
        $item['it_id'] = '';
    }

    return $item;
}
}


2. lib / shop.lib.php 내용에서  before_check_cart_price  검색후 내용이 없으면 끝에 아래 내용 추가합니다.
if(!function_exists("before_check_cart_price")) {
// 장바구니 금액 체크 $is_price_update 가 true 이면 장바구니 가격 업데이트한다. 
function before_check_cart_price($s_cart_id, $is_ct_select_condition=false, $is_price_update=false, $is_item_cache=false){
    global $g5, $default, $config;
    if( !$s_cart_id ){
        return;
    }
    $select_where_add = '';
    if( $is_ct_select_condition ){
        $select_where_add = " and ct_select = '0' ";
    }
    $sql = " select * from `{$g5['g5_shop_cart_table']}` where od_id = '{$s_cart_id}' {$select_where_add} ";
    $result = sql_query($sql);
    $check_need_update = false;
    
    for ($i=0; $row = sql_fetch_array($result); $i++){
        if( ! $row['it_id'] ) continue;
        $it_id = $row['it_id'];
        $it = get_shop_item($it_id, $is_item_cache);
        
        $update_querys = array();
        if(!$it['it_id'])
            continue;
        
        if( $it['it_price'] !== $row['ct_price'] ){
            // 장바구니 테이블 상품 가격과 상품 테이블의 상품 가격이 다를경우
            $update_querys['ct_price'] = $it['it_price'];
        }
        if( $row['io_id'] ){
            $io_sql = " select * from `{$g5['g5_shop_item_option_table']}` where it_id = '{$it['it_id']}' and io_id = '{$row['io_id']}' ";
            $io_infos = sql_fetch( $io_sql );
            if( $io_infos['io_type'] ){
                $this_io_type = $io_infos['io_type'];
            }
            if( $io_infos['io_id'] && $io_infos['io_price'] !== $row['io_price'] ){
                // 장바구니 테이블 옵션 가격과 상품 옵션테이블의 옵션 가격이 다를경우
                $update_querys['io_price'] = $io_infos['io_price'];
            }
        }
        // 포인트
        $compare_point = 0;
        if($config['cf_use_point']) {
            // DB 에 io_type 이 1이면 상품추가옵션이며, 0이면 상품선택옵션이다
            if($row['io_type'] == 0) {
                $compare_point = get_item_point($it, $row['io_id']);
            } else {
                $compare_point = $it['it_supply_point'];
            }
            if($compare_point < 0)
                $compare_point = 0;
        }
        
        if((int) $row['ct_point'] !== (int) $compare_point){
            // 장바구니 테이블 적립 포인트와 상품 테이블의 적립 포인트가 다를경우
            $update_querys['ct_point'] = $compare_point;
        }
        if( $update_querys ){
            $check_need_update = true;
        }
        // 장바구니에 담긴 금액과 실제 상품 금액에 차이가 있고, $is_price_update 가 true 인 경우 장바구니 금액을 업데이트 합니다. 
        if( $is_price_update && $update_querys ){
            $conditions = array();
            foreach ($update_querys as $column => $value) {
                $conditions[] = "`{$column}` = '{$value}'";
            }
            if( $col_querys = implode(',', $conditions) ) {
                $sql_query = "update `{$g5['g5_shop_cart_table']}` set {$col_querys} where it_id = '{$it['it_id']}' and od_id = '{$s_cart_id}' and ct_id = '{$row['ct_id']}' ";
                sql_query($sql_query, false);
            }
        }
    }
    // 장바구니에 담긴 금액과 실제 상품 금액에 차이가 있다면
    if( $check_need_update ){
        return false;
    }
    return true;
}
}


3. shop/cart.php 에  before_check_cart_price 가 있는지 확인하고, 없으면  include_once('./_common.php');  밑에 아래 내용을 추가합니다.
if(function_exists('before_check_cart_price')) {
    before_check_cart_price($s_cart_id, true, true, true);
}



참고자료
https://sir.kr/qa/503815
label

댓글목록

등록된 댓글이 없습니다.


Total 416건 1 페이지
  • RSS
기술자료 목록
416
그누보드   452  2025-02-07 08:55 ~ 2025-02-07 17:04  
415
영카트   822  2024-10-21 13:44 ~ 2024-10-21 19:42  
414
Java   1793  2024-02-06 16:49  
413
PHP   1984  2024-02-06 16:42  
열람
영카트   2112  2024-01-04 14:57  
411
그누보드   2733  2023-11-06 20:38  
410
영카트   2441  2023-10-07 23:31  
409
그누보드   3684  2023-04-07 18:22 ~ 2023-04-07 18:40  
408
그누보드   3644  2023-04-07 08:45 ~ 2023-04-07 10:00  
407
그누보드   4334  2023-04-06 22:37  
406
호스팅   3699  2023-03-06 15:52 ~ 2023-12-18 16:54  
405
그누보드   4091  2023-02-03 16:25  
404
그누보드   2648  2023-01-20 19:39 ~ 2023-01-20 23:13  
403
MySQL   4414  2022-12-28 21:09 ~ 2022-12-29 06:32  
402
그누보드   4042  2022-11-10 20:41 ~ 2022-11-14 01:03  
401
영카트   4613  2022-06-17 00:07 ~ 2022-06-17 00:08  
400
그누보드   4253  2022-06-11 00:52  
399
영카트   6901  2022-01-28 09:48 ~ 2023-01-26 01:50  
398
그누보드   5454  2021-12-22 08:54 ~ 2021-12-22 08:56  
397
그누보드   5280  2021-11-21 05:59 ~ 2021-11-24 00:20  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.