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

영카트 레벨별 결제금액 설정

· 9년 전 · 9577 · 21
안녕하세요. 매일 눈팅이랑 필요한것만 쏙 빼가다가
마침 레벨별로 결제금액설정 하는 기능을 써야해서 진행하다가

상품올리는 db table과 카트로 옮기는 db table 이 달라서
업데이트 부분만 찾아내면 쉽게 바꿀수 있겠다 생각하여
해본 결과 생각보다 간단하고 쉽게 바꿀수 있게 되어
초보자분들을 위하여 글을 남깁니다.

방식은 상품올리기할때 최하단부분의 필드를 이용하는 방법입니다.

건드릴 부분은

1. /skin/shop/basic/item.form.skin.php 테마를 사용하시면 /theme/테마폴더/mobile/skin/shop/basic/item.form.skin.php

2. /shop/cartupdate.php

3. 가격이 표시되는 파일들 메인 리스트 등
ex) 1- /mall/theme/kidstore/mobile/skin/shop/basic/main.10.skin.php
2- /mall/theme/kidstore/mobile/skin/shop/basic/list.10.skin.php




1. 상세페이지 아이템폼( /skin/shop/basic/item.form.skin.php )

[code]

<?php if ($it['it_origin']) { ?>
<tr>
<th scope="row">원산지</th>
<td><?php echo $it['it_origin']; ?></td>
</tr>
<?php } ?>

<?php if ($it['it_brand']) { ?>
<tr>
<th scope="row">브랜드</th>
<td><?php echo $it['it_brand']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_model']) { ?>
<tr>
<th scope="row">모델</th>
<td><?php echo $it['it_model']; ?></td>
</tr>
<?php } ?>
<?php if (!$it['it_use']) { // 판매가능이 아닐 경우 ?>
<tr>
<th scope="row">판매가격</th>
<td>판매중지</td>
</tr>
<?php } else if ($it['it_tel_inq']) { // 전화문의일 경우 ?>
<tr>
<th scope="row">판매가격</th>
<td>전화문의</td>
</tr>
<?php } else { // 전화문의가 아닐 경우?>
<?php if ($it['it_cust_price']) { // 1.00.03?>
<tr>
<th scope="row">시중가격</th>
<td><SPAN style="text-decoration:line-through;"><?php echo display_price($it['it_cust_price']); ?></SPAN></td>
</tr>
<?php } ?>

///////////////////////////여기부터////////////////////////

<? if ($member[mb_level] >= 6 | $is_admin == 'super'){ ?>

<tr>
<th scope="row">판매가격</th>
<td>
<font style="font-size:18px; font-weight:bold; color:#F3435D;"><?php echo display_price($it['it_1']); ?></font> //요기와
<input type="hidden" id="it_price" value="<?php echo $it['it_1']; ?>"> //요기
</td>
</tr>

<? }else { ?>

<tr>
<th scope="row">판매가격</th>
<td>
<font style="font-size:18px; font-weight:bold; color:#F3435D;"><?php echo display_price(get_price($it)); ?></font>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>

<? } ?>


/////////////////////////////여기까지///////////////////////////


<?php } ?>

<?php
/* 재고 표시하는 경우 주석 해제
<tr>
<th scope="row">재고수량</th>
<td><?php echo number_format(get_it_stock_qty($it_id)); ?> 개</td>
</tr>
*/
?>

[/code]

보시면 알겠지만 it_price 를 레벨6이상일때 it_1 으로 치환시켜
필드1에 적은 판매가격을 보여주는 부분을 1번필드값으로 치환합니다.
간단하죠^^

이정도면 다들 아시겠지만 elseif 문으로 나열하면 레벨에 따른
필드사용이 가능합니다. 생초보분들을 위하여 가벼운 예시를 넣겠습니다.




[code]

<?php if ($it['it_origin']) { ?>
<tr>
<th scope="row">원산지</th>
<td><?php echo $it['it_origin']; ?></td>
</tr>
<?php } ?>

<?php if ($it['it_brand']) { ?>
<tr>
<th scope="row">브랜드</th>
<td><?php echo $it['it_brand']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_model']) { ?>
<tr>
<th scope="row">모델</th>
<td><?php echo $it['it_model']; ?></td>
</tr>
<?php } ?>
<?php if (!$it['it_use']) { // 판매가능이 아닐 경우 ?>
<tr>
<th scope="row">판매가격</th>
<td>판매중지</td>
</tr>
<?php } else if ($it['it_tel_inq']) { // 전화문의일 경우 ?>
<tr>
<th scope="row">판매가격</th>
<td>전화문의</td>
</tr>
<?php } else { // 전화문의가 아닐 경우?>
<?php if ($it['it_cust_price']) { // 1.00.03?>
<tr>
<th scope="row">시중가격</th>
<td><SPAN style="text-decoration:line-through;"><?php echo display_price($it['it_cust_price']); ?></SPAN></td>
</tr>
<?php } ?>

///////////////////////////여기부터////////////////////////

<? if ($member[mb_level] >= 6 | $is_admin == 'super'){ ?>

<tr>
<th scope="row">판매가격</th>
<td>
<font style="font-size:18px; font-weight:bold; color:#F3435D;"><?php echo display_price($it['it_1']); ?></font> //요기와
<input type="hidden" id="it_price" value="<?php echo $it['it_1']; ?>"> //요기
</td>
</tr>

<? }elseif ($member[mb_level] >= 4 ){ ?>

<tr>
<th scope="row">판매가격</th>
<td>
<font style="font-size:18px; font-weight:bold; color:#F3435D;"><?php echo display_price($it['it_2']); ?></font>
<input type="hidden" id="it_price" value="<?php echo $it['it_2']; ?>">
</td>
</tr>


<? }else { ?>

<tr>
<th scope="row">판매가격</th>
<td>
<font style="font-size:18px; font-weight:bold; color:#F3435D;"><?php echo display_price(get_price($it)); ?></font>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>

<? } ?>


/////////////////////////////여기까지///////////////////////////


<?php } ?>

<?php
/* 재고 표시하는 경우 주석 해제
<tr>
<th scope="row">재고수량</th>
<td><?php echo number_format(get_it_stock_qty($it_id)); ?> 개</td>
</tr>
*/
?>

[/code]

보시는 것과 같이 4이하일때 일반가격, 4이상 6이하일때 2번필드,
6이상일때 1번필드로 가격이 나오게 됩니다.

주의할 점은 이렇게 코드를 하면 1번,2번 필드를 가격이 같더라도
무조건 작성을 해주어야 합니다.

가령 2번필드가 필요없어 안적었는데 레벨5인분이 상품을 보면 0원으로
표시가 됩니다.





2. 카트업데이트 ( /shop/cartupdate.php )


[code]

// 배송비결제
if($it['it_sc_type'] == 1)
$ct_send_cost = 2; // 무료
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
$ct_send_cost = 1; // 착불


///////////////////////////////////////////////////////////318줄 하단정도에/////////////

if ($member[mb_level] >= 6 | $is_admin == 'super'){

$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_1']}', '$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' )";

}else{

$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' )";
}


/////////////////////////여기까지//////////////////////////

$comma = ' , ';
$ct_count++;
}

if($ct_count > 0)
sql_query($sql);
}
}


[/code]


보시면 알겠지만 it_price 를 레벨6이상일때 it_1 으로 치환시켜
필드1 값을 op_price 테이블로 업데이트시켜버리는 것입니다.

이정도면 다들 아시겠지만 elseif 문으로 나열하면 레벨에 따른
필드사용이 가능합니다. 생초보분들을 위하여 가벼운 예시를 넣겠습니다.


[code]

// 배송비결제
if($it['it_sc_type'] == 1)
$ct_send_cost = 2; // 무료
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
$ct_send_cost = 1; // 착불


///////////////////////////////////////////////////////////318줄 하단정도에/////////////

if ($member[mb_level] >= 6 | $is_admin == 'super'){

$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_1']}', '$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' )";


}elseif ($member[mb_level] >= 4){
$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_2']}', '$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' )";


}else{
$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' )";
}


/////////////////////////여기까지/////////////

$comma = ' , ';
$ct_count++;
}

if($ct_count > 0)
sql_query($sql);
}
}


[/code]

이것은 4이하일때 일반가격, 4이상 6이하일때 2번필드,
6이상일때 1번필드로 가격이 나오게 됩니다.

주의할 점은 이렇게 코드를 하면 1번,2번 필드를 가격이 같더라도
무조건 작성을 해주어야 합니다.

가령 2번필드가 필요없어 안적었는데 레벨5인분이 상품을 보면 0원으로
업데이트가 됩니다.





3. 가격이 표시되는 파일들 메인 리스트 등
ex) 1- /mall/theme/kidstore/mobile/skin/shop/basic/main.10.skin.php
2- /mall/theme/kidstore/mobile/skin/shop/basic/list.10.skin.php
등등





[code]

if ($this->view_it_cust_price || $this->view_it_price) {

//레벨별 가격설정

if ($member[mb_level] >= 6 | $is_admin == 'super'){

echo "<div class=\"sct_cost\">\n";

if ($this->view_it_cust_price && $row['it_cust_price']) {
echo "<span class=\"cust_price\">".display_price($row['it_cust_price'])."</span>\n";
}


if ($this->view_it_price) {
echo display_price($row['it_1'], $row['it_tel_inq'])."\n"; //판매가격을 1번필드로 설정
}

echo "</div>\n";

}else{

echo "<div class=\"sct_cost\">\n";

if ($this->view_it_cust_price && $row['it_cust_price']) {
echo "<span class=\"cust_price\">".display_price($row['it_cust_price'])."</span>\n";
}



if ($this->view_it_price) {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}

echo "</div>\n";

}
//레벨별 가격설정

}

[/code]


mian.10.skin.php등의 파일을 보면

if ($this->view_it_cust_price || $this->view_it_price) 이런식으로 되어있는

부분이 있습니다. 그 가격 부분을 수정하는 것인데 위 처럼 if, else 기본문으로

레벨설정하고 가격 부분에 1번 필드로 치환하면 끝입니다.



와~ 생각보다 팁쓰는일이 힘드네요. 매일 훔쳐가기만하다가 이제야 하나 공유하네요.
고수님들은 이런 쉬운 팁은 필요없으시니 백버튼 눌러주시고 초보님들은 질문하여주시면
시간되는데로 댓글쪽지 나누겠습니다.

감사합니다~

댓글 작성

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

로그인하기

댓글 21개

정말 필요했던 기능이었는데.. 감사합니다^^

게시글 목록

번호 제목
2169
2168
2167
2158
2146
2140
2130
2114
2102
2095
2084
2075
2072
2070
2069
2065
2058
2056
2055
2054
2049
2038
2036
1989
1956
1923
1918
1904
1892
1891