영카트 [YC5] 특정회원 상품 가격 % 할인
페이지 정보

본문
상품 일괄 할인율을 적용하는 방법입니다
지정된 % 가 일괄 할인해서 구매가 이뤄지도록 합니다
1. 파일 구조
그누보드
├ adm
│ ├ shop_admin
│ │ ├ itemsellform.php ( New )
│ │ └ itemsellformupdate.php ( New )
│ └ admin.menu400.shop_1of2.php ( Edit )
├ js
│ └shop.override_sell_count.js ( New )
├ lib
│ ├ naverpay.lib.php ( Edit )
│ └ shop.lib.php ( Edit )
├ mobile
│ └ skin
│ └ shop
│ └ basic
│ ├ list.10.skin.php ( Edit )
│ ├ item.form.skin.php ( Edit )
│ └ main.10.skin.php ( Edit )
├ shop
│ ├ naverpay
│ │ ├ naver_item.php ( Edit )
│ │ └ naver_order.php ( Edit )
│ └ cartupdate.php ( Edit )
├ skin
│ └ shop
│ └ basic
│ ├ list.10.skin.php ( Edit )
│ ├ item.form.skin.php ( Edit )
│ └ main.10.skin.php ( Edit )
└ theme
└ basic
├ mobile
│ └ skin
│ └ shop
│ └ basic
│ ├ list.10.skin.php ( Edit )
│ ├ item.form.skin.php ( Edit )
│ └ main.10.skin.php ( Edit )
└ skin
└ shop
└ basic
├ list.10.skin.php ( Edit )
├ item.form.skin.php ( Edit )
└ main.10.skin.php ( Edit )
이윰빌더 작업시 추가
그누보드
├ adm
│ ├ eyoom_admin (이윰빌더)
│ │ ├ core
│ │ │ └ shop
│ │ │ ├ itemsellform.php ( New )
│ │ │ └ itemsellformupdate.php ( New )
│ │ └ theme
│ │ └ basic
│ │ └ skin
│ │ └ shop
│ │ └ itemsellform.html.php ( New )
└ theme
└ eyoom_basic (이윰빌더)
└ skin
└ shop
└ basic
├ list.10.skin.html.php ( Edit )
└ item.form.skin.html.php ( Edit )
2. 디비의 g5_shop_default 에 de_sell_count 필드를 추가
환경설정 > 쇼핑몰 > 일괄할인 메뉴를 클릭하면 자동 생성
3. / adm / admin.menu400.shop_1of2.php
array('400100', '쇼핑몰설정', G5_ADMIN_URL.'/shop_admin/configform.php', 'scf_config'),
아래 내용 추가
array('400310', '일괄할인', G5_ADMIN_URL.'/shop_admin/itemsellform.php', 'itemsellform'),
4. / adm / shop_admin / itemsellform.php 생성
<?php
// /adm/shop_admin/itemsellform.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);
}
if(!sql_query(" select de_sell_count_level from {$g5['g5_shop_default_table']} limit 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD `de_sell_count_level` varchar(2) COMMENT '일괄할인 레벨' ", true);
}
?>
<form name="fitemform" action="./itemsellformupdate.php" method="post" autocomplete="off">
<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="number"
name="de_sell_count"
value="<?php echo (int)$default['de_sell_count']; ?>"
id="de_sell_count"
class="frm_input"
size="8"
min="0"
max="100"> %
</td>
</tr>
<tr>
<th scope="row"><label for="de_sell_count">할인적용 레벨</label></th>
<td>
<?php echo help("할인율이 적용되는 회원레벨을 지정합니다."); ?>
<select name="de_sell_count_level" class="frm_input">
<option value="">사용안함</option>
<?php for($i=1; $i<=10; $i++) { ?>
<option value="<?php echo $i; ?>"
<?php echo ($default['de_sell_count_level']==$i?'selected':''); ?>>
<?php echo $i; ?> 레벨
</option>
<?php } ?>
</select>
</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');
5. / adm / shop_admin / itemsellformupdate.php 생성
<?php
// /adm/shop_admin/itemsellformupdate.php
$sub_menu = '400310';
include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], "w");
check_admin_token();
/* ==========================
입력값 정리
========================== */
$de_sell_count = isset($_POST['de_sell_count']) ? (int)$_POST['de_sell_count'] : 0;
$de_sell_count_level = isset($_POST['de_sell_count_level']) ? (int)$_POST['de_sell_count_level'] : 0;
/* ==========================
유효성 검증
========================== */
// 할인율 범위
if ($de_sell_count < 0 || $de_sell_count > 100) {
alert('일괄 할인율은 0 ~ 100 사이의 숫자만 입력할 수 있습니다.');
}
// 레벨 범위 (0 = 사용안함)
if ($de_sell_count_level < 0 || $de_sell_count_level > 10) {
alert('할인 적용 레벨 값이 올바르지 않습니다.');
}
/* ==========================
저장
========================== */
$sql = "
UPDATE {$g5['g5_shop_default_table']}
SET
de_sell_count = '{$de_sell_count}',
de_sell_count_level = '{$de_sell_count_level}'
";
sql_query($sql);
/* ==========================
이동
========================== */
goto_url('./itemsellform.php');
6. / lib/shop.lib.php 수정
function get_price($it)
{
if ($it['it_tel_inq']) return '전화문의';
$price = $it['it_price'];
return (int)$price;
}
를 아래와 같이 수정
// 테스트 아이디
if (!function_exists('is_test_member')) {
function is_test_member($member = null) {
if (!is_array($member)) {
return false;
}
if (empty($member['mb_id'])) {
return false;
}
// 테스트 계정 목록
$test_ids = ['아이디1', '아이디2', '아이디3'];
return in_array($member['mb_id'], $test_ids, true);
}
}
function get_price($it)
{
global $member, $default;
// 회원 레벨
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
if ($it['it_tel_inq']) return '전화문의';
// 일괄할인 조건
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
$targetLv = isset($default['de_sell_count_level']) ? (int)$default['de_sell_count_level'] : 0;
$rate = isset($default['de_sell_count']) ? (int)$default['de_sell_count'] : 0;
$is_global_discount = (
$rate > 0 &&
$targetLv > 0 &&
$mb_level === $targetLv
);
if ($mb_level === 10) {
$price = $it['it_price'];
} else if (
$is_global_discount
//&& is_test_member($member)
) {
$price = $it['it_price'];
} else {
$price = $it['it_price'];
}
return (int)$price;
}
// 일괄할인
function get_global_sell_discount_price($price, $member) {
global $default, member;
$price = (int)$price;
$rate = (int)$default['de_sell_count'];
$targetLv = (int)$default['de_sell_count_level'];
$is_target_level = ((int)$member['mb_level'] === $targetLv);
// 테스트 계정만 적용
//if (!is_test_member($member)) { return $price; }
if (
$price <= 0 ||
$rate <= 0 ||
$targetLv <= 0 ||
!is_array($member) ||
!isset($member['mb_level']) ||
(int)$member['mb_level'] !== $targetLv
) {
return $price;
}
return floor($price * (100 - $rate) / 100);
}
7. / 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' )";
를 아래와 같이 변경
// 일괄할인
// 1. 일괄할인 조건
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
$targetLv = isset($default['de_sell_count_level']) ? (int)$default['de_sell_count_level'] : 0;
$rate = isset($default['de_sell_count']) ? (int)$default['de_sell_count'] : 0;
$is_global_discount = (
$rate > 0 &&
$targetLv > 0 &&
$mb_level === $targetLv
);
// 2. 회원 등급별 기준가 결정
if ($mb_level === 10) {
$it_price = $it['it_price'];
} else if (
$is_global_discount
//&& is_test_member($member)
) { // 일괄할인 대상 → 무조건 원가
$it_price = get_global_sell_discount_price((int)$it['it_price'], $member);
} else { // 기본가
$it_price = (int)$it['it_price'];
}
// 3. 옵션 가격은 그대로 사용
$io_price = (int)$io_price;
// 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_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' )";
8-1. / skin / shop / basic / list.10.skin.php
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
를 아래와 같이 변경
if ($this->view_it_price) {
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
}
8-2. / mobile / skin / shop / basic / list.10.skin.php
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
echo "</div>\n";
}
를 아래와 같이 변경
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
echo "</div>\n";
9-1. / skin / shop / basic / main.10.skin.php
if ($this->view_it_price) {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
를 아래와 같이 변경
if ($this->view_it_price) {
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
}
9-2. / mobile / skin / shop / basic / main.10.skin.php
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
echo "</div>\n";
}
를 아래와 같이 변경
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
echo "</div>\n";
}
10-1. / skin / shop / basic / item.form.skin.php
<tr class="tr_price">
<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 class="tr_price">
<th scope="row">판매가격</th>
<td>
<?php
// 일괄할인 해피정닷컴
// 실제 표시 기준가
$origin_price = (int)get_price($it);
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
$is_discount = ($sell_price < $origin_price);
if ($is_discount) {
?>
<strong class="price_origin">
<del><?php echo number_format($origin_price); ?>원</del>
</strong>
<span class="discount_rate">
<?php echo (int)$default['de_sell_count']; ?>% 할인
</span><br>
<strong class="price_sell">
<?php echo number_format($sell_price); ?>원
</strong>
<input type="hidden" id="it_price" value="<?php echo $sell_price; ?>">
<?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>
10-2. / mobile / skin / shop / basic / item.form.skin.php
<tr>
<th scope="row">판매가격</th>
<td>
<?php echo display_price(get_price($it)); ?>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
를 아래와 같이 변경
<tr>
<th scope="row">판매가격</th>
<td>
<?php
// 일괄할인
// 실제 표시 기준가
$origin_price = (int)get_price($it);
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
$is_discount = ($sell_price < $origin_price);
if ($is_discount) {
?>
<strong class="price_origin">
<del><?php echo number_format($origin_price); ?>원</del>
</strong>
<span class="discount_rate">
<?php echo (int)$default['de_sell_count']; ?>% 할인
</span><br>
<strong class="price_sell">
<?php echo number_format($sell_price); ?>원
</strong>
<input type="hidden" id="it_price" value="<?php echo $sell_price; ?>">
<?php
} else {
?>
<?php echo display_price(get_price($it)); ?>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php
}
?>
</td>
</tr>
11-1. / lib / naverpay.lib.php
function get_sendcost()
{
global $g5, $default;
를 아래와 같이 수정
function get_sendcost()
{
//global $g5, $default;
// 일괄할인
global $g5, $default, $member;
// 회원 정보 // 일괄할인
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
11-2. / lib / naverpay.lib.php
function get_sendcost()
{
...
$uprice = get_price($it);
를 아래와 같이 변경
//$uprice = get_price($it);
// 1. 기준가 // 일괄할인
$base_price = (int)$it['it_price'];
// 2. 회원 등급 일괄할인
$uprice = get_global_sell_discount_price($base_price, $member);
11-3. / lib / naverpay.lib.php
function query()
{
global $g5, $default;
를 아래와 같이 수정
function query()
{
//global $g5, $default;
// 일괄할인
global $g5, $default, $member;
// 회원 정보 // 일괄할인
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
11-4. / lib / naverpay.lib.php
function query()
{
...
$uprice = get_price($it);
를 아래와 같이 변경
//$uprice = get_price($it);
// 1. 기준가 // 일괄할인
$base_price = (int)$it['it_price'];
// 2 회원 등급 일괄할인
$uprice = get_global_sell_discount_price($base_price, $member);
11-5. / lib / naverpay.lib.php
$query .= '&NAVER_INFLOW_CODE='.urlencode($_COOKIE['NA_CO']);
를 아래와 같이 변경
//$query .= '&NAVER_INFLOW_CODE='.urlencode($_COOKIE['NA_CO']);
$na_co = isset($_COOKIE['NA_CO']) ? $_COOKIE['NA_CO'] : ''; // 일괄할인
$query .= '&NAVER_INFLOW_CODE='.urlencode($na_co); // 일괄할인
12. shop / naverpay / naver_item.php
기존 파일은 백업하고 아래 내용으로 모두 교체
<?php
// /shop/naverpay/naver_item.php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/naverpay.lib.php');
// --------------------------------------------------
// QUERY STRING 파싱 (안정 처리)
// --------------------------------------------------
$query = $_SERVER['QUERY_STRING'];
$vars = array();
foreach (explode('&', $query) as $pair) {
$tmp = explode('=', $pair, 2);
if (count($tmp) !== 2) continue;
$key = urldecode($tmp[0]);
$value = preg_replace("/[^A-Za-z0-9\-_]/", "", urldecode($tmp[1]));
$vars[$key][] = $value;
}
$itemIds = isset($vars['ITEM_ID']) ? $vars['ITEM_ID'] : array();
if (count($itemIds) < 1) {
exit('ITEM_ID 는 필수입니다.');
}
// --------------------------------------------------
// XML HEADER
// --------------------------------------------------
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<response>
<?php
// --------------------------------------------------
// 회원 정보 (일괄할인)
// --------------------------------------------------
global $member;
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
// --------------------------------------------------
// ITEM LOOP
// --------------------------------------------------
foreach ($itemIds as $it_id) {
$sql = " SELECT * FROM {$g5['g5_shop_item_table']} WHERE it_id = '{$it_id}' ";
$it = sql_fetch($sql);
if (!$it || !$it['it_id']) continue;
$id = $it['it_id'];
$name = $it['it_name'];
$description = $it['it_basic'];
$image = get_naverpay_item_image_url($it_id);
$quantity = get_naverpay_item_stock($it_id);
$returnInfo = get_naverpay_return_info($it['it_seller']);
$option = get_naverpay_item_option($it_id, $it['it_option_subject']);
// 카테고리
$ca_name = $ca_name2 = $ca_name3 = '';
if ($it['ca_id']) {
$cat = sql_fetch(" SELECT ca_name FROM {$g5['g5_shop_category_table']} WHERE ca_id = '{$it['ca_id']}' ");
$ca_name = $cat['ca_name'];
}
if ($it['ca_id2']) {
$cat = sql_fetch(" SELECT ca_name FROM {$g5['g5_shop_category_table']} WHERE ca_id = '{$it['ca_id2']}' ");
$ca_name2 = $cat['ca_name'];
}
if ($it['ca_id3']) {
$cat = sql_fetch(" SELECT ca_name FROM {$g5['g5_shop_category_table']} WHERE ca_id = '{$it['ca_id3']}' ");
$ca_name3 = $cat['ca_name'];
}
// --------------------------------------------------
// 1. 회원 등급 기준가
// --------------------------------------------------
$base_price = (int)$it['it_price'];
// --------------------------------------------------
// 2. 전역 일괄할인 적용
// --------------------------------------------------
$price = get_global_sell_discount_price($base_price, $member);
?>
<item id="<?php echo $id; ?>">
<?php if ($it['ec_mall_pid']) { ?>
<name><![CDATA[<?php echo $it['ec_mall_pid']; ?>]]></name>
<?php } ?>
<name><![CDATA[<?php echo $name; ?>]]></name>
<url><?php echo G5_SHOP_URL.'/item.php?it_id='.$it_id; ?></url>
<description><![CDATA[<?php echo $description; ?>]]></description>
<image><?php echo $image; ?></image>
<thumb><?php echo $image; ?></thumb>
<price><?php echo $price; ?></price>
<quantity><?php echo $quantity; ?></quantity>
<category>
<first id="MJ01"><![CDATA[<?php echo $ca_name; ?>]]></first>
<second id="ML01"><![CDATA[<?php echo $ca_name2; ?>]]></second>
<third id="MN01"><![CDATA[<?php echo $ca_name3; ?>]]></third>
</category>
<?php echo $option; ?>
<?php echo $returnInfo; ?>
</item>
<?php
}
?>
</response>
13-1. shop / naverpay / naver_order.php
<?php
include_once('./_common.php');
를 아래와 같이 변경
<?php\
include_once('./_common.php');\
// 회원 레벨
global $member;
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
13-2. shop / naverpay / naver_order.php
$it_price = get_price($it);
아래에 내용 추가
// 기준가 일괄할인
$base_price = (int)$it['it_price'];
// 전역 일괄할인 적용
$it_price = get_global_sell_discount_price($base_price, $member);
//$it_price = get_price($it);
이윰빌더 사용시 작업
1. 이윰빌더/adm / eyoom_admin / core / basic / skin/ shop / itemsellform.php 생성
<?php
if (!defined('_EYOOM_IS_ADMIN_')) exit;
$sub_menu = '400310';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$action_url1 = G5_ADMIN_URL . '/?dir=shop&pid=itemsellformupdate&smode=1';
// 재입고알림 설정 필드 추가
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);
}
2. 이윰빌더/adm / eyoom_admin / core / basic / skin/ shop / itemsellformupdate.php 생성
<?php
if (!defined('_EYOOM_IS_ADMIN_')) exit;
$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");
alert("적용하였습니다.", G5_ADMIN_URL . "/?dir=shop&pid=itemsellform");
3. 이윰빌더/adm / eyoom_admin / theme / basic / skin/ shop / itemsellform.html.php 생성
<?php
if (!defined('_EYOOM_IS_ADMIN_')) exit;
add_stylesheet('<link rel="stylesheet" href="'.EYOOM_ADMIN_THEME_URL.'/plugins/jsgrid/jsgrid.min.css" type="text/css" media="screen">',0);
add_stylesheet('<link rel="stylesheet" href="'.EYOOM_ADMIN_THEME_URL.'/plugins/jsgrid/jsgrid-theme.min.css" type="text/css" media="screen">',0);
?>
<form name="fitemform" action="<?php echo $action_url1; ?>" 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>
4. 이윰빌더/theme / eyoom_basic / skin / shop / basic / list10.skin.html.php
<?php if ($this->view_it_price) { ?>
<span class="title-price">₩ <?php echo $list[$i]['it_tel_inq']; ?></span>
<?php } ?>
<?php if ($this->view_it_cust_price && $list[$i]['it_cust_price']) { ?>
<span class="title-price line-through">₩ <?php echo $list[$i]['it_cust_price']; ?></span>
<?php } ?>
를 아래와 같이 변경
<?php
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
if ($default['de_sell_count'] > 0) { // 일괄할인 실사용
?>
<?php if ($this->view_it_price) { ?>
<span class="title-price"><strike>₩ <?php echo $list[$i]['it_tel_inq']; ?></strike></span>
<?php echo " <span style='font-size:0.8em;'>({$default['de_sell_count']}% 할인)</span><br> "; ?>
<span class="title-price">₩ <?php echo number_Format($list[$i]['it_price'] - (int)($list[$i]['it_price'] * $default['de_sell_count'] / 100)); ?></span>
<?php } ?>
<?php if ($this->view_it_cust_price && $list[$i]['it_cust_price']) { ?>
<span class="title-price line-through">₩ <?php echo $list[$i]['it_cust_price']; ?></span>
<?php } ?>
<?php
} else {
?>
<?php if ($this->view_it_price) { ?>
<span class="title-price">₩ <?php echo $list[$i]['it_tel_inq']; ?></span>
<?php } ?>
<?php if ($this->view_it_cust_price && $list[$i]['it_cust_price']) { ?>
<span class="title-price line-through">₩ <?php echo $list[$i]['it_cust_price']; ?></span>
<?php } ?>
<?php
}
?>
5. 이윰빌더/theme / eyoom_basic / skin / shop / basic / item.form.skin.html.php
<tr>
<th scope="row">판매가격</th>
<td>
<strong class="shop-product-prices"><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php if ($it['it_cust_price']) { ?>
<span class="line-through"><?php echo display_price($it['it_cust_price']); ?></span>
<?php } ?>
</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 class="shop-product-prices"><?php echo display_price(get_price($it) - (int)(get_price($it) * $default['de_sell_count'] / 100)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it) - (int)(get_price($it) * $default['de_sell_count'] / 100); ?>">
<?php if ($it['it_cust_price']) { ?>
<span class="line-through"><?php echo display_price($it['it_cust_price']); ?></span>
<?php } ?>
<?php
} else {
?>
<strong class="shop-product-prices"><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php if ($it['it_cust_price']) { ?>
<span class="line-through"><?php echo display_price($it['it_cust_price']); ?></span>
<?php } ?>
<?php
}
?>
</td>
</tr>
6. 이윰빌더/theme / eyoom_basic / skin / shop / basic / item.form.skin.html.php
<script src="<?php echo G5_JS_URL; ?>/shop.override.js"></script>
를 아래와 같이 변경
<?php
// 일괄할인
if ($default['de_sell_count'] > 0) { // 일괄할인 실사용
?>
<script src="<?php echo G5_JS_URL; ?>/shop.override_sell_count.js?ver=<?php //echo time(); ?>"></script>
<script>
if (typeof price_calculate === "function") {
price_calculate = (function() {
var cached_function = price_calculate;
return function() {
if( $(".2017_renewal_itemform").length ){
var it_price = parseInt($("input#it_price").val());
if(isNaN(it_price))
return;
var $el_prc = $("input.io_price");
var $el_qty = $("input[name^=ct_qty]");
var $el_type = $("input[name^=io_type]");
var price, type, qty, total = 0;
$el_prc.each(function(index) {
price = parseInt($(this).val());
qty = parseInt($el_qty.eq(index).val());
type = $el_type.eq(index).val();
if(type == "0") { // 선택옵션
total += (it_price + price - parseInt(price * <?php echo $default['de_sell_count']; ?> / 100)) * qty;
} else { // 추가옵션
total += (price - parseInt(price * <?php echo $default['de_sell_count']; ?> / 100)) * qty;
}
});
$("#sit_tot_price").empty().html("<span>총 금액. </span><strong>"+number_format(String(total))+"</strong> 원");
$("#sit_tot_price").trigger("price_calculate", [total]);
} else {
cached_function.apply(this, arguments); // use .apply() to call it
}
};
}());
} //end if check function
</script>
<?php
} else {
?>
<script src="<?php echo G5_JS_URL; ?>/shop.override.js"></script>
<?php
}
?>
지정된 % 가 일괄 할인해서 구매가 이뤄지도록 합니다
1. 파일 구조
그누보드
├ adm
│ ├ shop_admin
│ │ ├ itemsellform.php ( New )
│ │ └ itemsellformupdate.php ( New )
│ └ admin.menu400.shop_1of2.php ( Edit )
├ js
│ └
├ lib
│ ├ naverpay.lib.php ( Edit )
│ └ shop.lib.php ( Edit )
├ mobile
│ └ skin
│ └ shop
│ └ basic
│ ├ list.10.skin.php ( Edit )
│ ├ item.form.skin.php ( Edit )
│ └ main.10.skin.php ( Edit )
├ shop
│ ├ naverpay
│ │ ├ naver_item.php ( Edit )
│ │ └ naver_order.php ( Edit )
│ └ cartupdate.php ( Edit )
├ skin
│ └ shop
│ └ basic
│ ├ list.10.skin.php ( Edit )
│ ├ item.form.skin.php ( Edit )
│ └ main.10.skin.php ( Edit )
└ theme
└ basic
├ mobile
│ └ skin
│ └ shop
│ └ basic
│ ├ list.10.skin.php ( Edit )
│ ├ item.form.skin.php ( Edit )
│ └ main.10.skin.php ( Edit )
└ skin
└ shop
└ basic
├ list.10.skin.php ( Edit )
├ item.form.skin.php ( Edit )
└ main.10.skin.php ( Edit )
이윰빌더 작업시 추가
그누보드
├ adm
│ ├ eyoom_admin (이윰빌더)
│ │ ├ core
│ │ │ └ shop
│ │ │ ├ itemsellform.php ( New )
│ │ │ └ itemsellformupdate.php ( New )
│ │ └ theme
│ │ └ basic
│ │ └ skin
│ │ └ shop
│ │ └ itemsellform.html.php ( New )
└ theme
└ eyoom_basic (이윰빌더)
└ skin
└ shop
└ basic
├ list.10.skin.html.php ( Edit )
└ item.form.skin.html.php ( Edit )
2. 디비의 g5_shop_default 에 de_sell_count 필드를 추가
환경설정 > 쇼핑몰 > 일괄할인 메뉴를 클릭하면 자동 생성
3. / adm / admin.menu400.shop_1of2.php
array('400100', '쇼핑몰설정', G5_ADMIN_URL.'/shop_admin/configform.php', 'scf_config'),
아래 내용 추가
array('400310', '일괄할인', G5_ADMIN_URL.'/shop_admin/itemsellform.php', 'itemsellform'),
4. / adm / shop_admin / itemsellform.php 생성
<?php
// /adm/shop_admin/itemsellform.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);
}
if(!sql_query(" select de_sell_count_level from {$g5['g5_shop_default_table']} limit 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}`
ADD `de_sell_count_level` varchar(2) COMMENT '일괄할인 레벨' ", true);
}
?>
<form name="fitemform" action="./itemsellformupdate.php" method="post" autocomplete="off">
<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="number"
name="de_sell_count"
value="<?php echo (int)$default['de_sell_count']; ?>"
id="de_sell_count"
class="frm_input"
size="8"
min="0"
max="100"> %
</td>
</tr>
<tr>
<th scope="row"><label for="de_sell_count">할인적용 레벨</label></th>
<td>
<?php echo help("할인율이 적용되는 회원레벨을 지정합니다."); ?>
<select name="de_sell_count_level" class="frm_input">
<option value="">사용안함</option>
<?php for($i=1; $i<=10; $i++) { ?>
<option value="<?php echo $i; ?>"
<?php echo ($default['de_sell_count_level']==$i?'selected':''); ?>>
<?php echo $i; ?> 레벨
</option>
<?php } ?>
</select>
</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');
5. / adm / shop_admin / itemsellformupdate.php 생성
<?php
// /adm/shop_admin/itemsellformupdate.php
$sub_menu = '400310';
include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], "w");
check_admin_token();
/* ==========================
입력값 정리
========================== */
$de_sell_count = isset($_POST['de_sell_count']) ? (int)$_POST['de_sell_count'] : 0;
$de_sell_count_level = isset($_POST['de_sell_count_level']) ? (int)$_POST['de_sell_count_level'] : 0;
/* ==========================
유효성 검증
========================== */
// 할인율 범위
if ($de_sell_count < 0 || $de_sell_count > 100) {
alert('일괄 할인율은 0 ~ 100 사이의 숫자만 입력할 수 있습니다.');
}
// 레벨 범위 (0 = 사용안함)
if ($de_sell_count_level < 0 || $de_sell_count_level > 10) {
alert('할인 적용 레벨 값이 올바르지 않습니다.');
}
/* ==========================
저장
========================== */
$sql = "
UPDATE {$g5['g5_shop_default_table']}
SET
de_sell_count = '{$de_sell_count}',
de_sell_count_level = '{$de_sell_count_level}'
";
sql_query($sql);
/* ==========================
이동
========================== */
goto_url('./itemsellform.php');
6. / lib/shop.lib.php 수정
function get_price($it)
{
if ($it['it_tel_inq']) return '전화문의';
$price = $it['it_price'];
return (int)$price;
}
를 아래와 같이 수정
// 테스트 아이디
if (!function_exists('is_test_member')) {
function is_test_member($member = null) {
if (!is_array($member)) {
return false;
}
if (empty($member['mb_id'])) {
return false;
}
// 테스트 계정 목록
$test_ids = ['아이디1', '아이디2', '아이디3'];
return in_array($member['mb_id'], $test_ids, true);
}
}
function get_price($it)
{
global $member, $default;
// 회원 레벨
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
if ($it['it_tel_inq']) return '전화문의';
// 일괄할인 조건
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
$targetLv = isset($default['de_sell_count_level']) ? (int)$default['de_sell_count_level'] : 0;
$rate = isset($default['de_sell_count']) ? (int)$default['de_sell_count'] : 0;
$is_global_discount = (
$rate > 0 &&
$targetLv > 0 &&
$mb_level === $targetLv
);
if ($mb_level === 10) {
$price = $it['it_price'];
} else if (
$is_global_discount
//&& is_test_member($member)
) {
$price = $it['it_price'];
} else {
$price = $it['it_price'];
}
return (int)$price;
}
// 일괄할인
function get_global_sell_discount_price($price, $member) {
global $default, member;
$price = (int)$price;
$rate = (int)$default['de_sell_count'];
$targetLv = (int)$default['de_sell_count_level'];
$is_target_level = ((int)$member['mb_level'] === $targetLv);
// 테스트 계정만 적용
//if (!is_test_member($member)) { return $price; }
if (
$price <= 0 ||
$rate <= 0 ||
$targetLv <= 0 ||
!is_array($member) ||
!isset($member['mb_level']) ||
(int)$member['mb_level'] !== $targetLv
) {
return $price;
}
return floor($price * (100 - $rate) / 100);
}
7. / 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' )";
를 아래와 같이 변경
// 일괄할인
// 1. 일괄할인 조건
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
$targetLv = isset($default['de_sell_count_level']) ? (int)$default['de_sell_count_level'] : 0;
$rate = isset($default['de_sell_count']) ? (int)$default['de_sell_count'] : 0;
$is_global_discount = (
$rate > 0 &&
$targetLv > 0 &&
$mb_level === $targetLv
);
// 2. 회원 등급별 기준가 결정
if ($mb_level === 10) {
$it_price = $it['it_price'];
} else if (
$is_global_discount
//&& is_test_member($member)
) { // 일괄할인 대상 → 무조건 원가
$it_price = get_global_sell_discount_price((int)$it['it_price'], $member);
} else { // 기본가
$it_price = (int)$it['it_price'];
}
// 3. 옵션 가격은 그대로 사용
$io_price = (int)$io_price;
// 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_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' )";
8-1. / skin / shop / basic / list.10.skin.php
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
를 아래와 같이 변경
if ($this->view_it_price) {
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
}
8-2. / mobile / skin / shop / basic / list.10.skin.php
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
echo "</div>\n";
}
를 아래와 같이 변경
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
echo "</div>\n";
9-1. / skin / shop / basic / main.10.skin.php
if ($this->view_it_price) {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
를 아래와 같이 변경
if ($this->view_it_price) {
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
}
9-2. / mobile / skin / shop / basic / main.10.skin.php
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
echo "</div>\n";
}
를 아래와 같이 변경
if ($this->view_it_price) {
echo "<div class=\"sct_cost\">\n";
//echo display_price(get_price($row), $row['it_tel_inq'])."\n";
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
// 기본 상품가
$origin_price = (int)$row['it_price'];
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
// 할인 여부
$is_discount = ($sell_price < $origin_price);
if ($is_discount) { // 일괄할인 실사용
// 정가 (취소선)
echo "<span class=\"sct_price_origin\"><del>"
. number_format($origin_price)
. "원</del></span><br>\n";
// 할인가
echo "<span class=\"sct_price_sell\">"
. number_format($sell_price)
. "원</span><br>\n";
// 할인 뱃지
echo "<span class=\"sct_price_badge\">회원할인 "
. (int)$default['de_sell_count']
. "%</span>\n";
} else {
echo display_price(get_price($row), $row['it_tel_inq'])."\n";
}
echo "</div>\n";
}
10-1. / skin / shop / basic / item.form.skin.php
<tr class="tr_price">
<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 class="tr_price">
<th scope="row">판매가격</th>
<td>
<?php
// 일괄할인 해피정닷컴
// 실제 표시 기준가
$origin_price = (int)get_price($it);
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
$is_discount = ($sell_price < $origin_price);
if ($is_discount) {
?>
<strong class="price_origin">
<del><?php echo number_format($origin_price); ?>원</del>
</strong>
<span class="discount_rate">
<?php echo (int)$default['de_sell_count']; ?>% 할인
</span><br>
<strong class="price_sell">
<?php echo number_format($sell_price); ?>원
</strong>
<input type="hidden" id="it_price" value="<?php echo $sell_price; ?>">
<?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>
10-2. / mobile / skin / shop / basic / item.form.skin.php
<tr>
<th scope="row">판매가격</th>
<td>
<?php echo display_price(get_price($it)); ?>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
를 아래와 같이 변경
<tr>
<th scope="row">판매가격</th>
<td>
<?php
// 일괄할인
// 실제 표시 기준가
$origin_price = (int)get_price($it);
// 전역 할인 적용가 (공통 함수)
$sell_price = get_global_sell_discount_price($origin_price, $member);
$is_discount = ($sell_price < $origin_price);
if ($is_discount) {
?>
<strong class="price_origin">
<del><?php echo number_format($origin_price); ?>원</del>
</strong>
<span class="discount_rate">
<?php echo (int)$default['de_sell_count']; ?>% 할인
</span><br>
<strong class="price_sell">
<?php echo number_format($sell_price); ?>원
</strong>
<input type="hidden" id="it_price" value="<?php echo $sell_price; ?>">
<?php
} else {
?>
<?php echo display_price(get_price($it)); ?>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php
}
?>
</td>
</tr>
11-1. / lib / naverpay.lib.php
function get_sendcost()
{
global $g5, $default;
를 아래와 같이 수정
function get_sendcost()
{
//global $g5, $default;
// 일괄할인
global $g5, $default, $member;
// 회원 정보 // 일괄할인
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
11-2. / lib / naverpay.lib.php
function get_sendcost()
{
...
$uprice = get_price($it);
를 아래와 같이 변경
//$uprice = get_price($it);
// 1. 기준가 // 일괄할인
$base_price = (int)$it['it_price'];
// 2. 회원 등급 일괄할인
$uprice = get_global_sell_discount_price($base_price, $member);
11-3. / lib / naverpay.lib.php
function query()
{
global $g5, $default;
를 아래와 같이 수정
function query()
{
//global $g5, $default;
// 일괄할인
global $g5, $default, $member;
// 회원 정보 // 일괄할인
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
11-4. / lib / naverpay.lib.php
function query()
{
...
$uprice = get_price($it);
를 아래와 같이 변경
//$uprice = get_price($it);
// 1. 기준가 // 일괄할인
$base_price = (int)$it['it_price'];
// 2 회원 등급 일괄할인
$uprice = get_global_sell_discount_price($base_price, $member);
11-5. / lib / naverpay.lib.php
$query .= '&NAVER_INFLOW_CODE='.urlencode($_COOKIE['NA_CO']);
를 아래와 같이 변경
//$query .= '&NAVER_INFLOW_CODE='.urlencode($_COOKIE['NA_CO']);
$na_co = isset($_COOKIE['NA_CO']) ? $_COOKIE['NA_CO'] : ''; // 일괄할인
$query .= '&NAVER_INFLOW_CODE='.urlencode($na_co); // 일괄할인
12. shop / naverpay / naver_item.php
기존 파일은 백업하고 아래 내용으로 모두 교체
<?php
// /shop/naverpay/naver_item.php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/naverpay.lib.php');
// --------------------------------------------------
// QUERY STRING 파싱 (안정 처리)
// --------------------------------------------------
$query = $_SERVER['QUERY_STRING'];
$vars = array();
foreach (explode('&', $query) as $pair) {
$tmp = explode('=', $pair, 2);
if (count($tmp) !== 2) continue;
$key = urldecode($tmp[0]);
$value = preg_replace("/[^A-Za-z0-9\-_]/", "", urldecode($tmp[1]));
$vars[$key][] = $value;
}
$itemIds = isset($vars['ITEM_ID']) ? $vars['ITEM_ID'] : array();
if (count($itemIds) < 1) {
exit('ITEM_ID 는 필수입니다.');
}
// --------------------------------------------------
// XML HEADER
// --------------------------------------------------
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<response>
<?php
// --------------------------------------------------
// 회원 정보 (일괄할인)
// --------------------------------------------------
global $member;
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
// --------------------------------------------------
// ITEM LOOP
// --------------------------------------------------
foreach ($itemIds as $it_id) {
$sql = " SELECT * FROM {$g5['g5_shop_item_table']} WHERE it_id = '{$it_id}' ";
$it = sql_fetch($sql);
if (!$it || !$it['it_id']) continue;
$id = $it['it_id'];
$name = $it['it_name'];
$description = $it['it_basic'];
$image = get_naverpay_item_image_url($it_id);
$quantity = get_naverpay_item_stock($it_id);
$returnInfo = get_naverpay_return_info($it['it_seller']);
$option = get_naverpay_item_option($it_id, $it['it_option_subject']);
// 카테고리
$ca_name = $ca_name2 = $ca_name3 = '';
if ($it['ca_id']) {
$cat = sql_fetch(" SELECT ca_name FROM {$g5['g5_shop_category_table']} WHERE ca_id = '{$it['ca_id']}' ");
$ca_name = $cat['ca_name'];
}
if ($it['ca_id2']) {
$cat = sql_fetch(" SELECT ca_name FROM {$g5['g5_shop_category_table']} WHERE ca_id = '{$it['ca_id2']}' ");
$ca_name2 = $cat['ca_name'];
}
if ($it['ca_id3']) {
$cat = sql_fetch(" SELECT ca_name FROM {$g5['g5_shop_category_table']} WHERE ca_id = '{$it['ca_id3']}' ");
$ca_name3 = $cat['ca_name'];
}
// --------------------------------------------------
// 1. 회원 등급 기준가
// --------------------------------------------------
$base_price = (int)$it['it_price'];
// --------------------------------------------------
// 2. 전역 일괄할인 적용
// --------------------------------------------------
$price = get_global_sell_discount_price($base_price, $member);
?>
<item id="<?php echo $id; ?>">
<?php if ($it['ec_mall_pid']) { ?>
<name><![CDATA[<?php echo $it['ec_mall_pid']; ?>]]></name>
<?php } ?>
<name><![CDATA[<?php echo $name; ?>]]></name>
<url><?php echo G5_SHOP_URL.'/item.php?it_id='.$it_id; ?></url>
<description><![CDATA[<?php echo $description; ?>]]></description>
<image><?php echo $image; ?></image>
<thumb><?php echo $image; ?></thumb>
<price><?php echo $price; ?></price>
<quantity><?php echo $quantity; ?></quantity>
<category>
<first id="MJ01"><![CDATA[<?php echo $ca_name; ?>]]></first>
<second id="ML01"><![CDATA[<?php echo $ca_name2; ?>]]></second>
<third id="MN01"><![CDATA[<?php echo $ca_name3; ?>]]></third>
</category>
<?php echo $option; ?>
<?php echo $returnInfo; ?>
</item>
<?php
}
?>
</response>
13-1. shop / naverpay / naver_order.php
<?php
include_once('./_common.php');
를 아래와 같이 변경
<?php\
include_once('./_common.php');\
// 회원 레벨
global $member;
$mb_level = isset($member['mb_level']) ? (int)$member['mb_level'] : 0;
13-2. shop / naverpay / naver_order.php
$it_price = get_price($it);
아래에 내용 추가
// 기준가 일괄할인
$base_price = (int)$it['it_price'];
// 전역 일괄할인 적용
$it_price = get_global_sell_discount_price($base_price, $member);
//$it_price = get_price($it);
이윰빌더 사용시 작업
1. 이윰빌더/adm / eyoom_admin / core / basic / skin/ shop / itemsellform.php 생성
<?php
if (!defined('_EYOOM_IS_ADMIN_')) exit;
$sub_menu = '400310';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$action_url1 = G5_ADMIN_URL . '/?dir=shop&pid=itemsellformupdate&smode=1';
// 재입고알림 설정 필드 추가
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);
}
2. 이윰빌더/adm / eyoom_admin / core / basic / skin/ shop / itemsellformupdate.php 생성
<?php
if (!defined('_EYOOM_IS_ADMIN_')) exit;
$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");
alert("적용하였습니다.", G5_ADMIN_URL . "/?dir=shop&pid=itemsellform");
3. 이윰빌더/adm / eyoom_admin / theme / basic / skin/ shop / itemsellform.html.php 생성
<?php
if (!defined('_EYOOM_IS_ADMIN_')) exit;
add_stylesheet('<link rel="stylesheet" href="'.EYOOM_ADMIN_THEME_URL.'/plugins/jsgrid/jsgrid.min.css" type="text/css" media="screen">',0);
add_stylesheet('<link rel="stylesheet" href="'.EYOOM_ADMIN_THEME_URL.'/plugins/jsgrid/jsgrid-theme.min.css" type="text/css" media="screen">',0);
?>
<form name="fitemform" action="<?php echo $action_url1; ?>" 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>
4. 이윰빌더/theme / eyoom_basic / skin / shop / basic / list10.skin.html.php
<?php if ($this->view_it_price) { ?>
<span class="title-price">₩ <?php echo $list[$i]['it_tel_inq']; ?></span>
<?php } ?>
<?php if ($this->view_it_cust_price && $list[$i]['it_cust_price']) { ?>
<span class="title-price line-through">₩ <?php echo $list[$i]['it_cust_price']; ?></span>
<?php } ?>
를 아래와 같이 변경
<?php
// 일괄할인
//if ($default['de_sell_count'] > 0 && ($member['mb_id']=='테스트아이디')) { // 일괄할인 테스트
if ($default['de_sell_count'] > 0) { // 일괄할인 실사용
?>
<?php if ($this->view_it_price) { ?>
<span class="title-price"><strike>₩ <?php echo $list[$i]['it_tel_inq']; ?></strike></span>
<?php echo " <span style='font-size:0.8em;'>({$default['de_sell_count']}% 할인)</span><br> "; ?>
<span class="title-price">₩ <?php echo number_Format($list[$i]['it_price'] - (int)($list[$i]['it_price'] * $default['de_sell_count'] / 100)); ?></span>
<?php } ?>
<?php if ($this->view_it_cust_price && $list[$i]['it_cust_price']) { ?>
<span class="title-price line-through">₩ <?php echo $list[$i]['it_cust_price']; ?></span>
<?php } ?>
<?php
} else {
?>
<?php if ($this->view_it_price) { ?>
<span class="title-price">₩ <?php echo $list[$i]['it_tel_inq']; ?></span>
<?php } ?>
<?php if ($this->view_it_cust_price && $list[$i]['it_cust_price']) { ?>
<span class="title-price line-through">₩ <?php echo $list[$i]['it_cust_price']; ?></span>
<?php } ?>
<?php
}
?>
5. 이윰빌더/theme / eyoom_basic / skin / shop / basic / item.form.skin.html.php
<tr>
<th scope="row">판매가격</th>
<td>
<strong class="shop-product-prices"><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php if ($it['it_cust_price']) { ?>
<span class="line-through"><?php echo display_price($it['it_cust_price']); ?></span>
<?php } ?>
</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 class="shop-product-prices"><?php echo display_price(get_price($it) - (int)(get_price($it) * $default['de_sell_count'] / 100)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it) - (int)(get_price($it) * $default['de_sell_count'] / 100); ?>">
<?php if ($it['it_cust_price']) { ?>
<span class="line-through"><?php echo display_price($it['it_cust_price']); ?></span>
<?php } ?>
<?php
} else {
?>
<strong class="shop-product-prices"><?php echo display_price(get_price($it)); ?></strong>
<input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">
<?php if ($it['it_cust_price']) { ?>
<span class="line-through"><?php echo display_price($it['it_cust_price']); ?></span>
<?php } ?>
<?php
}
?>
</td>
</tr>
6. 이윰빌더/theme / eyoom_basic / skin / shop / basic / item.form.skin.html.php
<script src="<?php echo G5_JS_URL; ?>/shop.override.js"></script>
를 아래와 같이 변경
<?php
// 일괄할인
if ($default['de_sell_count'] > 0) { // 일괄할인 실사용
?>
<script src="<?php echo G5_JS_URL; ?>/shop.override_sell_count.js?ver=<?php //echo time(); ?>"></script>
<script>
if (typeof price_calculate === "function") {
price_calculate = (function() {
var cached_function = price_calculate;
return function() {
if( $(".2017_renewal_itemform").length ){
var it_price = parseInt($("input#it_price").val());
if(isNaN(it_price))
return;
var $el_prc = $("input.io_price");
var $el_qty = $("input[name^=ct_qty]");
var $el_type = $("input[name^=io_type]");
var price, type, qty, total = 0;
$el_prc.each(function(index) {
price = parseInt($(this).val());
qty = parseInt($el_qty.eq(index).val());
type = $el_type.eq(index).val();
if(type == "0") { // 선택옵션
total += (it_price + price - parseInt(price * <?php echo $default['de_sell_count']; ?> / 100)) * qty;
} else { // 추가옵션
total += (price - parseInt(price * <?php echo $default['de_sell_count']; ?> / 100)) * qty;
}
});
$("#sit_tot_price").empty().html("<span>총 금액. </span><strong>"+number_format(String(total))+"</strong> 원");
$("#sit_tot_price").trigger("price_calculate", [total]);
} else {
cached_function.apply(this, arguments); // use .apply() to call it
}
};
}());
} //end if check function
</script>
<?php
} else {
?>
<script src="<?php echo G5_JS_URL; ?>/shop.override.js"></script>
<?php
}
?>
댓글목록
등록된 댓글이 없습니다.

