boxcart.skin.php 장바구니 가격의 총 합 출력하기
본문
<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);
$sell_price = $sum['ct_price'];
$tot_sell_price += $sell_price;
$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'], 65, 65, true);
echo '<div class="prd_img">'.$it_img.'</div>';
echo '<div class="prd_cnt">';
echo '<a class="prd_name">'.$it_name.'</a>';
echo '<span class="prd_cost">';
echo number_format($row['ct_price']).PHP_EOL;
echo '원';
echo '</span>'.PHP_EOL;
echo '</div>';
echo '<button class="cart_del" type="button" data-it_id="'.$row['it_id'].'"><img src="'.G5_THEME_URL.'/img/close.png"><span class="sound_only">삭제</span></button>'.PHP_EOL;
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>
<div><strong><?php echo number_format($tot_sell_price); ?></strong> 원 </div>
<?php if($i){ ?><div class="btn_buy" style="display:none;"><button type="submit" class="btn_submit">구매하기</button></div>
<?php } ?>
<!-- <a href="<?php echo G5_SHOP_URL; ?>/cart.php" class="go_cart">전체보기</a> -->
</form>
number_format($row['ct_price']) 로 출력된 장바구니 목록의 가격 합을 나타내고싶은데 어떻게 적어야 나타날까요?!
!-->답변 1
<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);
//$sell_price = $sum['ct_price'];
//$tot_sell_price += $sell_price;
$tot_sell_price = 0;
$i = 0;
foreach($cart_datas as $row)
{
if( !$row['it_id'] ) continue;
$tot_sell_price += (int)$row['ct_price'];
echo '<li>';
$it_name = get_text($row['it_name']);
// 이미지로 할 경우
$it_img = get_it_image($row['it_id'], 65, 65, true);
echo '<div class="prd_img">'.$it_img.'</div>';
echo '<div class="prd_cnt">';
echo '<a class="prd_name">'.$it_name.'</a>';
echo '<span class="prd_cost">';
echo number_format($row['ct_price']).PHP_EOL;
echo '원';
echo '</span>'.PHP_EOL;
echo '</div>';
echo '<button class="cart_del" type="button" data-it_id="'.$row['it_id'].'"><img src="'.G5_THEME_URL.'/img/close.png"><span class="sound_only">삭제</span></button>'.PHP_EOL;
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>
<div><strong><?php echo number_format($tot_sell_price); ?></strong> 원 </div>
<?php if($i){ ?><div class="btn_buy" style="display:none;"><button type="submit" class="btn_submit">구매하기</button></div>
<?php } ?>
<!-- <a href="<?php echo G5_SHOP_URL; ?>/cart.php" class="go_cart">전체보기</a> -->
</form>
답변을 작성하시기 전에 로그인 해주세요.