[쇼핑몰] 동일 상품일때 갯수만 올라가기 > 팁앤테크

본문 바로가기

사이트 내 전체검색

뒤로가기 팁앤테크

[쇼핑몰] 동일 상품일때 갯수만 올라가기

본문

같은 제품을 장바구니에 넣으면 수량이 추가되는것이 아니라 새로운 아이템으로 추가 됩니다.
 
/shop/cartupdate.php를 보면 같은 아이템의 수량을 구해서 재고확인에만 사용하고 있네요.
만일 같은 제품이 존재한다면 cart에 insert를 하지 말고 update를 하는게 더 바람직하죠 ^^
 
/shop/cartupdate.php에서 ... 164라인 부근을 다음과 같이 바꾸어 줍니다.
 
    //--------------------------------------------------------
    // 사양이 같은 상품 검사
    //--------------------------------------------------------
    $sql = " select SUM(ct_qty) as cnt from $g4[yc4_cart_table]
              where it_id = '$_POST[it_id]'
                and on_uid = '$tmp_on_uid'
                and it_opt1 = '$_POST[it_opt1]' and it_opt2 = '$_POST[it_opt2]' and it_opt3 = '$_POST[it_opt3]' and it_opt4 = '$_POST[it_opt4]' and it_opt5 = '$_POST[it_opt5]' and it_opt6 = '$_POST[it_opt6]' ";
    $row = sql_fetch($sql);
    $real_sum_qty = $row[cnt];   
    if ($real_sum_qty > 0) { // 같은 사양제품이 있으면
    $sql = " update $g4[yc4_cart_table] set ct_qty = ct_qty + $_POST[ct_qty]
              where it_id = '$_POST[it_id]'
                and on_uid = '$tmp_on_uid'
                and it_opt1 = '$_POST[it_opt1]' and it_opt2 = '$_POST[it_opt2]' and it_opt3 = '$_POST[it_opt3]' and it_opt4 = '$_POST[it_opt4]' and it_opt5 = '$_POST[it_opt5]' and it_opt6 = '$_POST[it_opt6]' ";
    sql_query($sql);
    } else {
    // 장바구니에 Insert
    $sql = " insert $g4[yc4_cart_table]
                set on_uid       = '$tmp_on_uid',
                    it_id        = '$_POST[it_id]',
                    it_opt1      = '$_POST[it_opt1]',
                    it_opt2      = '$_POST[it_opt2]',
                    it_opt3      = '$_POST[it_opt3]',
                    it_opt4      = '$_POST[it_opt4]',
                    it_opt5      = '$_POST[it_opt5]',
                    it_opt6      = '$_POST[it_opt6]',
                    ct_status    = '쇼핑',
                    ct_amount    = '$_POST[it_amount]',
                    ct_point     = '$_POST[it_point]',
                    ct_point_use = '0',
                    ct_stock_use = '0',
                    ct_qty       = '$_POST[ct_qty]',
                    ct_time      = '$g4[time_ymdhis]',
                    ct_ip        = '$REMOTE_ADDR' ";
    sql_query($sql);

    }
}
추천0

댓글목록 0

등록된 댓글이 없습니다.

전체 29건 1 페이지
게시물 검색
Copyright (c) 株式会社YHPLUS. All rights reserved.

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒171-0014 東京都豊島区池袋2-41-5 アーバン154 8F
050-5539-7787
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

PC 버전으로 보기