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

영카트 버전별 (4.x vs 5.2 vs 5.3) 장바구니에 담긴 개수 구하기

· 7년 전 · 3730
영카트 버전에 따른 장바구니 개수를 제어하는 방법이 변경되었습니다.


1. 영카트 4.17.03

1-1. lib / shop.lib.php 내용
<?php
// 세션변수값 얻음
function get_session($session_name)
{
return $_SESSION[$session_name];
}

// 장바구니 건수 검사
function get_cart_count($on_uid)
{
global $g4;

$sql = " select count(ct_id) as cnt from $g4[yc4_cart_table] where on_uid = '$on_uid' ";
$row = sql_fetch($sql);
$cnt = (int)$row[cnt];
return $cnt;
}
?>


1-2. 장바구니에 담긴 개수 보기
<?=get_cart_count(get_session('ss_on_uid'));?>


1-3. 장바니에 담긴 목록보기
<?include_once("$g4[shop_path]/boxcart.inc.php");?>
shop / boxcart.inc.php
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>

<table cellpadding=0 cellspacing=0 bgcolor=#FFFFFF>
<tr><td><a href='<?=$g4[shop_path]?>/cart.php'><img src='<?=$g4[shop_img_path]?>/bar_cart.gif' border=0></a></td></tr>
<?
$hsql = " select a.it_id, b.it_name, a.ct_qty from $g4[yc4_cart_table] a, $g4[yc4_item_table] b
where a.on_uid = '".get_session('ss_on_uid')."'
and a.it_id = b.it_id
order by a.ct_id ";
$hresult = sql_query($hsql);
for ($i=0; $row=sql_fetch_array($hresult); $i++)
{
echo "<tr><td height=22><nobr style='display:block; overflow:hidden; width:170px;'>&nbsp;&nbsp;· ";
$it_name = get_text($row[it_name]);
// 이미지로 할 경우
//$it_name = get_it_image($row[it_id]."_s", 50, 50, $row[it_id]);
echo "<a href=\"$g4[shop_path]/cart.php\">$it_name</a></nobr></td></tr>\n";
}

if ($i==0)
echo "<tr><td><img src='$g4[shop_img_path]/nocart.gif'></td></tr>\n";
?>
</table>



2. 영카트 5.2.9.8.4

2-1. lib / shop.lib.php 내용
<?php
// 세션변수값 얻음
function get_session($session_name)
{
return isset($_SESSION[$session_name]) ? $_SESSION[$session_name] : '';
}

// 장바구니 건수 검사
function get_cart_count($cart_id)
{
global $g5, $default;

$sql = " select count(ct_id) as cnt from {$g5['g5_shop_cart_table']} where od_id = '$cart_id' ";
$row = sql_fetch($sql);
$cnt = (int)$row['cnt'];
return $cnt;
}
?>


2-2. 장바구니에 담긴 개수 보기
<?php echo get_cart_count(get_session('ss_cart_id'));?>


2-3. 장바니에 담긴 목록보기
<?php include_once(G5_SHOP_SKIN_PATH.'/boxcart.skin.php'); // 장바구니 ?>
theme / basic / skin / shop / basic / boxcart.skin.php
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">', 0);
?>

<!-- 장바구니 간략 보기 시작 { -->
<aside id="sbsk">
<h2>장바구니</h2>

<ul>
<?php
$hsql = " select it_id, it_name from {$g5['g5_shop_cart_table']} ";
$hsql .= " where od_id = '".get_session('ss_cart_id')."' group by it_id ";
$hresult = sql_query($hsql);
for ($i=0; $row=sql_fetch_array($hresult); $i++)
{
echo '<li>';
$it_name = get_text($row['it_name']);
// 이미지로 할 경우
//$it_name = get_it_image($row['it_id'], 50, 50, true);
echo '<a href="'.G5_SHOP_URL.'/cart.php">'.$it_name.'</a>';
echo '</li>';
}

if ($i==0)
echo '<li id="sbsk_empty">장바구니 상품 없음</li>'.PHP_EOL;
?>
</ul>

</aside>
<!-- } 장바구니 간략 보기 끝 -->



3. 영카트 5.3.1.2

3-1. lib / shop.lib.php 내용
<?php
// 세션변수값 얻음
function get_session($session_name)
{
return isset($_SESSION[$session_name]) ? $_SESSION[$session_name] : '';
}

// 장바구니 건수 검사
function get_cart_count($cart_id)
{
global $g5, $default;

$sql = " select count(ct_id) as cnt from {$g5['g5_shop_cart_table']} where od_id = '$cart_id' ";
$row = sql_fetch($sql);
$cnt = (int)$row['cnt'];
return $cnt;
}

//장바구니 간소 데이터 가져오기
function get_boxcart_datas($is_cache=false)
{
global $g5;

$cart_id = get_session("ss_cart_id");

if( !$cart_id ){
return array();
}

static $cache = array();

if( $is_cache && !empty($cache) ){
return $cache;
}

$sql = " select * from {$g5['g5_shop_cart_table']} ";
$sql .= " where od_id = '".$cart_id."' group by it_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$key = $row['it_id'];
$cache[$key] = $row;
}

return $cache;
}

//장바구니 간소 데이터 갯수 출력
function get_boxcart_datas_count()
{
$cart_datas = get_boxcart_datas(true);

return count($cart_datas);
}
?>


3-2. 장바구니에 담긴 개수 보기
<?php echo get_boxcart_datas_count(); ?>


3-3. 장바니에 담긴 목록보기
<?php include_once(G5_SHOP_SKIN_PATH.'/boxcart.skin.php'); // 장바구니 ?>
theme / basic / skin / shop / basic / boxcart.skin.php
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">', 0);
?>

<!-- 장바구니 간략 보기 시작 { -->
<aside id="sbsk" class="op_area">
<h2>장바구니</h2>
<form name="skin_frmcartlist" id="skin_sod_bsk_list" method="post" action="<?php echo G5_SHOP_URL.'/cartupdate.php'; ?>">
<ul>
<?php
$cart_datas = get_boxcart_datas(true);
$i = 0;
foreach($cart_datas as $row)
{
if( !$row['it_id'] ) continue;

echo '<li>';
$it_name = get_text($row['it_name']);
// 이미지로 할 경우
$it_img = get_it_image($row['it_id'], 60, 60, true);
echo '<a href="'.G5_SHOP_URL.'/cart.php">'.$it_name.'</a>';
echo '<div class="prd_img">'.$it_img.'</div>';
echo '</li>';

echo '<input type="hidden" name="act" value="buy" >';
echo '<input type="hidden" name="ct_chk['.$i.']" value="1" >';
echo '<input type="hidden" name="it_id['.$i.']" value="'.$row['it_id'].'">';
echo '<input type="hidden" name="it_name['.$i.']" value="'.$it_name.'">';

$i++;
} //end foreach

if ($i==0)
echo '<li class="li_empty">장바구니 상품 없음</li>'.PHP_EOL;
?>
</ul>
<?php if($i){ ?><button type="submit" class="btn02 btn_buy"><i class="fa fa-credit-card" aria-hidden="true"></i> 바로구매</button><?php } ?>
<a href="<?php echo G5_SHOP_URL; ?>/cart.php" class="btn01 go_cart">장바구니 바로가기</a>
</form>
</aside>
<!-- } 장바구니 간략 보기 끝 -->

댓글 작성

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

로그인하기

게시글 목록

번호 제목
1291
1283
1274
1264
1261
1258
1255
1247
1244
1237
1232
1220
1213
1202
1195
1192
1191
1182
1169
1160
1158
1156
1154
1152
1136
1129
1122
1112
1084
1074