테스트 사이트 - 개발 중인 베타 버전입니다

장바구니 동일 옵션 중복을 따로 저장하는 방법 채택완료

GO치삼 4년 전 조회 1,842

 // 동일옵션의 상품이 있으면 수량 더함

            $sql2 = " select ct_id, io_type, ct_qty

                        from {$g5['g5_shop_cart_table']}

                        where od_id = '$tmp_cart_id'

                          and it_id = '$it_id'

                          and io_id = '$io_id'

                          and ct_status = '쇼핑' ";

            $row2 = sql_fetch($sql2);

            if($row2['ct_id']) {

                if($it_id != $it_id) { 

                    $sql3 = " INSERT INTO {$g5['g5_shop_cart_table']}

                            ( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty,  it_qty_sub, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_method_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_select_time,ct_title,ct_msg, ct_file, advice)

                             VALUES ";

                             sql_query($sql3);

                        }

               

                // $sql3 = " update {$g5['g5_shop_cart_table']}

                //             set ct_qty = ct_qty + '$ct_qty'

                //             where ct_id = '{$row2['ct_id']}' ";

                // sql_query($sql3);

                continue;

            }

 

 

안녕하세요 위와같이 코드를 짰는데...

안먹히네요 어디가 잘못된건가요 ㅠㅠ

재고부분은 필요 없어서 날렸습니다..

 

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

답변 2개

채택된 답변
+20 포인트
정석코딩

if($it_id != $it_id) { 

                    $sql3 = " INSERT INTO {$g5['g5_shop_cart_table']}

                            ( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty,  it_qty_sub, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_method_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_select_time,ct_title,ct_msg, ct_file, advice)

                             VALUES ";

                             sql_query($sql3);

                        }

               

                // $sql3 = " update {$g5['g5_shop_cart_table']}

                //             set ct_qty = ct_qty + '$ct_qty'

                //             where ct_id = '{$row2['ct_id']}' ";

                // sql_query($sql3);

 

이 부분을..  대략 아래처럼 해야할 듯 하네요. 테스트는 안해봄.

</p>

<p>    if($it_id != $it_id) { </p>

<p>        $sql3 = " INSERT INTO {$g5['g5_shop_cart_table']}</p>

<p>                ( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty,  it_qty_sub, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_method_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_select_time,ct_title,ct_msg, ct_file, advice)</p>

<p>                    VALUES ";</p>

<p>                    sql_query($sql3);</p>

<p>    }else{</p>

<p>        $ct_qty = $row2['ct_qty'];

        $sql3 = " update {$g5['g5_shop_cart_table']}

                    set ct_qty = ct_qty + '$ct_qty'

                    where ct_id = '{$row2['ct_id']}' ";</p>

<p>        sql_query($sql3);

    }</p>

<p> </p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

G
GO치삼
4년 전
감사합니다 이 방법으로는 안해봤지만 해결했습니다!

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

4년 전

주석 처리한 부분은 위에 값넣는걸로 동일하게 변경해보세요.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

G
GO치삼
4년 전
감사합니다 이 법은 아니지만 해결했습니다~

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

답변을 작성하려면 로그인이 필요합니다.

로그인