상품 일괄 할인 적용하기 (2022-02-09 10:05 수정) 정보
상품 일괄 할인 적용하기 (2022-02-09 10:05 수정)
관련링크
본문
상품 일괄 할인율을 적용하는 방법입니다
지정된 % 가 일괄 할인해서 구매가 이뤄지도록 합니다
디비의 g5_shop_default 에 de_sell_count 필드를 추가
adm
└ admin.menu400.shop_1of2.php
adm / shop_admin
├ itemsellform.php
└ itemsellformupdate.php
shop
└ cartupdate.php
skin / shop / basic
└ item.form.skin.php
1. adm / admin.menu400.shop_1of2.php
아래 내용 추가
array('400310', '일괄할인', G5_ADMIN_URL.'/shop_admin/itemsellform.php', 'itemsellform'),
2. adm / shop_admin / itemsellform.php 생성
<?php
$sub_menu = '400310';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$html_title = "일괄할인";
$g5['title'] = $html_title;
include_once (G5_ADMIN_PATH.'/admin.head.php');
// 재입고알림 설정 필드 추가
if(!sql_query(" select de_sell_count from {$g5['g5_shop_default_table']} limit 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD `de_sell_count` tinyint(4) NOT NULL DEFAULT '0' COMMENT '일괄할인' ", true);
}
?>
<form name="fitemform" action="./itemsellformupdate.php" method="post" enctype="MULTIPART/FORM-DATA" autocomplete="off" onsubmit="return fitemformcheck(this)">
<input type="hidden" name="w" value="<?php echo $w; ?>">
<section id="anc_sitfrm_cate">
<h2 class="h2_frm">일괄할인</h2>
<?php echo $pg_anchor; ?>
<div class="local_desc02 local_desc">
<p>제품 가격을 비율로 일괄 할인 판매합니다</p>
</div>
<div class="tbl_frm01 tbl_wrap">
<table>
<caption>일괄할인</caption>
<colgroup>
<col class="grid_4">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row"><label for="de_sell_count">일괄할인</label></th>
<td>
<?php echo help("할인율이 0 이상일때 할인율이 작동합니다"); ?>
<input type="text" name="de_sell_count" value="<?php echo $default['de_sell_count']; ?>" id="de_sell_count" class="frm_input" size="8"> %
</td>
</tr>
</tbody>
</table>
</div>
</section>
<div class="btn_fixed_top">
<input type="submit" value="확인" class="btn_submit btn" accesskey="s">
</div>
</form>
<script>
var f = document.fitemform;
</script>
<?php
include_once (G5_ADMIN_PATH.'/admin.tail.php');
3. adm / shop_admin / itemsellformupdate.php 생성
<?php
$sub_menu = '400310';
include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], "w");
check_admin_token();
$sql = " update {$g5['g5_shop_default_table']}
set de_sell_count = '{$_POST['de_sell_count']}'
";
sql_query($sql);
goto_url("./itemsellform.php");
4. shop / cartupdate.php
$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' )";
를 아래와 같이 변경
$it_price = $it['it_price'];
//if ($default['de_sell_count']>0 && ($member['mb_id']=='테스트아이디')) { // 테스트할때 사용
if ($default['de_sell_count']>0) { // 일괄할인
$it_price = $it_price - ceil($it_price * $default['de_sell_count'] / 100);
}
$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_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}' )";
5. skin / shop / basic / item.form.skin.php
<tr>
<th scope="row">판매가격</th>
<td>
<strong><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
를 아래와 같이 변경
<tr>
<th scope="row">판매가격</th>
<td>
<?php // 일괄할인
//if ($default['de_sell_count']>0 && ($member['mb_id']=='테스트아이디')) { // 테스트할때 사용
if ($default['de_sell_count']>0) {
?>
<br>
<strong><strike><?php echo display_price(get_price($it)); ?></strike></strong> <?php echo $default['de_sell_count']; ?>% 할인<br>
<strong><?php echo display_price(get_price($it) - get_price($it) * $default['de_sell_count'] / 100); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it) - get_price($it) * $default['de_sell_count'] / 100; ?>">
<?php
} else {
?>
<strong><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php
}
?>
</td>
</tr>
지정된 % 가 일괄 할인해서 구매가 이뤄지도록 합니다
디비의 g5_shop_default 에 de_sell_count 필드를 추가
adm
└ admin.menu400.shop_1of2.php
adm / shop_admin
├ itemsellform.php
└ itemsellformupdate.php
shop
└ cartupdate.php
skin / shop / basic
└ item.form.skin.php
1. adm / admin.menu400.shop_1of2.php
아래 내용 추가
array('400310', '일괄할인', G5_ADMIN_URL.'/shop_admin/itemsellform.php', 'itemsellform'),
2. adm / shop_admin / itemsellform.php 생성
<?php
$sub_menu = '400310';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$html_title = "일괄할인";
$g5['title'] = $html_title;
include_once (G5_ADMIN_PATH.'/admin.head.php');
// 재입고알림 설정 필드 추가
if(!sql_query(" select de_sell_count from {$g5['g5_shop_default_table']} limit 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD `de_sell_count` tinyint(4) NOT NULL DEFAULT '0' COMMENT '일괄할인' ", true);
}
?>
<form name="fitemform" action="./itemsellformupdate.php" method="post" enctype="MULTIPART/FORM-DATA" autocomplete="off" onsubmit="return fitemformcheck(this)">
<input type="hidden" name="w" value="<?php echo $w; ?>">
<section id="anc_sitfrm_cate">
<h2 class="h2_frm">일괄할인</h2>
<?php echo $pg_anchor; ?>
<div class="local_desc02 local_desc">
<p>제품 가격을 비율로 일괄 할인 판매합니다</p>
</div>
<div class="tbl_frm01 tbl_wrap">
<table>
<caption>일괄할인</caption>
<colgroup>
<col class="grid_4">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row"><label for="de_sell_count">일괄할인</label></th>
<td>
<?php echo help("할인율이 0 이상일때 할인율이 작동합니다"); ?>
<input type="text" name="de_sell_count" value="<?php echo $default['de_sell_count']; ?>" id="de_sell_count" class="frm_input" size="8"> %
</td>
</tr>
</tbody>
</table>
</div>
</section>
<div class="btn_fixed_top">
<input type="submit" value="확인" class="btn_submit btn" accesskey="s">
</div>
</form>
<script>
var f = document.fitemform;
</script>
<?php
include_once (G5_ADMIN_PATH.'/admin.tail.php');
3. adm / shop_admin / itemsellformupdate.php 생성
<?php
$sub_menu = '400310';
include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], "w");
check_admin_token();
$sql = " update {$g5['g5_shop_default_table']}
set de_sell_count = '{$_POST['de_sell_count']}'
";
sql_query($sql);
goto_url("./itemsellform.php");
4. shop / cartupdate.php
$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' )";
를 아래와 같이 변경
$it_price = $it['it_price'];
//if ($default['de_sell_count']>0 && ($member['mb_id']=='테스트아이디')) { // 테스트할때 사용
if ($default['de_sell_count']>0) { // 일괄할인
$it_price = $it_price - ceil($it_price * $default['de_sell_count'] / 100);
}
$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_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}' )";
5. skin / shop / basic / item.form.skin.php
<tr>
<th scope="row">판매가격</th>
<td>
<strong><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
를 아래와 같이 변경
<tr>
<th scope="row">판매가격</th>
<td>
<?php // 일괄할인
//if ($default['de_sell_count']>0 && ($member['mb_id']=='테스트아이디')) { // 테스트할때 사용
if ($default['de_sell_count']>0) {
?>
<br>
<strong><strike><?php echo display_price(get_price($it)); ?></strike></strong> <?php echo $default['de_sell_count']; ?>% 할인<br>
<strong><?php echo display_price(get_price($it) - get_price($it) * $default['de_sell_count'] / 100); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it) - get_price($it) * $default['de_sell_count'] / 100; ?>">
<?php
} else {
?>
<strong><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php
}
?>
</td>
</tr>
추천
5
5
댓글 5개

대단히 감사합니다. 새해 복 많이 받으세요.
감사합니다!!

좋은정보 감사합니다.

반대로 일괄 인상하는것도 가능한건가요

@jude1234 소스에서 - 를 + 로 변경하면 일괄인상도 되기는 하죠
디비에서 가격을 변경하는 것이 아니라서, 인상용으로 사용하기에는 좀 애매할듯 싶네요
디비에서 가격을 변경하는 것이 아니라서, 인상용으로 사용하기에는 좀 애매할듯 싶네요