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

본문 바로가기
사이트 내 전체검색

팁앤테크

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

페이지 정보

profile_image
작성자 제로
댓글 0건 조회 47,826회 작성일 09-06-27 05:12

본문

같은 제품을 장바구니에 넣으면 수량이 추가되는것이 아니라 새로운 아이템으로 추가 됩니다.
 
/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);

    }
}

댓글목록

등록된 댓글이 없습니다.

Total 829건 1 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 날짜
829 제로 1102 06-18
828 제로 3833 03-21
827 제로 4167 02-23
826 제로 30616 11-02
825 제로 33842 07-10
824 제로 43538 04-06
823 제로 31546 02-21
822 제로 36977 12-31
821 제로 30695 12-24
820 제로 30489 12-04
819 제로 33178 10-17
818 제로 32045 10-02
817 제로 56800 08-04
816 제로 30426 08-04
815 제로 41036 08-03
814 제로 41497 07-08
813 제로 71115 07-08
812 제로 86003 07-06
811 제로 31718 06-09
810 제로 37404 06-03
809 제로 35772 04-16
808 제로 36319 03-29
807 제로 30737 03-26
806 제로 37944 03-12
805 제로 32884 03-10

검색

회원로그인

회원가입

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒140-0011 東京都品川区東大井2-5-9-203
050-5470-4714
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

접속자집계

오늘
6,531
어제
47,624
최대
431,155
전체
7,329,948
Copyright (c) 株式会社YHPLUS. All rights reserved.