묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
쇼핑몰에서요........배송료 추가 소스 알려주세요~ㅜ.ㅜ
2005.08.01 11:54
쇼핑몰에서요........
총 주문한금액이 9만원미만일경우 배송료 5,000원을 추가로 받고 싶은데요.
9만원이상은 무료배송이구요.........
그런데 배송료 5,000원 추가로 더 받게할려는 소스좀 알려주세요~ 파일은 product_basket.php 이구요.
밑에 소스 시작됩니다.
-------------------------------------------------------------------------------
<?
include "../include/common_inc.php";
// 장바구니 코드 생성하기 -----------------------------------------
if (strlen($HTTP_COOKIE_VARS["tempid"])==0) {
$tempid = md5(uniqid(rand()));
SetCookie("tempid","$tempid",0);
}else{
$tempid = $HTTP_COOKIE_VARS["tempid"];
}
// 새로 장바구니에 상품 추가
$basket_id = "tempid = '$tempid' and";
$qry_search = "SELECT * FROM fine_product_basket where $basket_id product_menuid = '$product_menuid'+ '+ ' and product_seqno = '$product_seqno' and product_ordernum = '+ 'X' order by seq_no desc";
$rst_search = mysql_query($qry_search);
$row_search = mysql_fetch_array($rst_search);
// echo "$qry_search <BR><BR>";
// $mode에 따른 작업처리 ----------------------------------------
switch($mode) {
case "update":
// 수량만 변경한(상품특성이 변하지 않은) 경우
$sql = "UPDATE fine_product_basket SET product_amount = $product_amount WHERE $basket_id seq_no='$product_seqno' AND product_ordernum = 'X'";
mysql_query($sql);
// echo "$sql <BR><BR>";
break;
case "del":
$sql = "DELETE FROM fine_product_basket WHERE $basket_id seq_no='$product_seqno' AND product_ordernum = 'X'";
mysql_query($sql);
// echo "$sql <BR><BR>";
break;
default :
if ($row_search){
// 상품 수량 추가
$amount_new = $row_search[product_amount] + $product_amount;
$sql = "update fine_product_basket set product_amount = $amount_new where $basket_id product_menuid = '$product_menuid' and product_seqno = '$product_seqno' and product_ordernum = 'X'";
mysql_query($sql);
// echo "$sql <BR><BR>";
} else {
// 상품 추가
$vdate = date("Ymd");
$sql = "INSERT INTO fine_product_basket
(seq_no, tempid, product_menuid, product_seqno, product_name, product_price, product_amount, product_ordernum, date)
VALUES ('', '$tempid', '$product_menuid', '$product_seqno', '$product_name', $product_price, '1', 'X', $vdate)";
mysql_query($sql);
// echo "$sql <BR><BR>";
}
break;
}
$qry = "SELECT * FROM fine_product_basket where $basket_id product_ordernum = 'X' order by seq_no desc";
$rst = mysql_query($qry);
// echo "$qry <BR><BR>";
function basket()
{
global $tempid,$rst,$product_menuid,$product_seqno,$form_num,$totalprice,$basket_menu_id;
$totalprice = 0;
$form_num = 0;
while($row = mysql_fetch_array($rst)){
$sumprice = $row[product_price] * $row[product_amount];
$form_num = $form_num+1;
echo "
<form name='form$form_num' action='$PHP_SELF' method='post'>
<input type=hidden name=product_seqno value="".$row[seq_no]."">
<input type=hidden name=product_menuid value="".$row[product_menuid]."">
<input type=hidden name=mode>
<TR align=center>
<TD><A HREF='product_detail.php?menu_id=$row[product_menuid]&seq_no=$row[product_seqno]'>$row[product_name]</A></TD>
<TD>".number_format($row[product_price])."</TD>
<TD>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td rowspan=2><input class='box' readonly name=product_amount size=2 value="".$row[product_amount]."" onChange="send(document.form$form_num,'update')" ></td>
<td width=20 align=center><a href=".javascriptfrm_up_qty(document.form$form_num,'update');"><img src="./images/up_icon.gif" width=15 height=13 border=0></a></td>
</tr>
<tr>
<td width=20 align=center><a href=".javascriptfrm_down_qty(document.form$form_num,'update');"><img src="./images/down_icon.gif" width=15 height=12 border=0></a></td>
</tr>
</table>
</TD>
<TD>".number_format($sumprice)."</TD>
<TD><a href=".javascriptsend(document.form$form_num,'del')"><FONT COLOR='red'><B>X</B></FONT></A></TD>
</TR>
</form>
";
$totalprice += $sumprice;
$basket_menu_id = $row[product_menuid];
}
if ($totalprice > 0) {
echo "
<TR height=30 bgcolor='D4E1EC'>
<TD colspan=3 align=right>Total : </TD>
<TD colspan=2 align=center>".number_format($totalprice)." 원</TD>
</TR>
";
}else{
echo "
<TR height=25>
<TD colspan=5 align=center>쇼핑하신 상품이 없습니다.</TD>
</TR>
";
}
}
$_INC_FILE = _BASE_DIR."/product_display/html/product_basket.html";
// 무조건 모든 파일에서 _MAIN_SKIN을 include 한다.
include _MAIN_SKIN;
?>
총 주문한금액이 9만원미만일경우 배송료 5,000원을 추가로 받고 싶은데요.
9만원이상은 무료배송이구요.........
그런데 배송료 5,000원 추가로 더 받게할려는 소스좀 알려주세요~ 파일은 product_basket.php 이구요.
밑에 소스 시작됩니다.
-------------------------------------------------------------------------------
<?
include "../include/common_inc.php";
// 장바구니 코드 생성하기 -----------------------------------------
if (strlen($HTTP_COOKIE_VARS["tempid"])==0) {
$tempid = md5(uniqid(rand()));
SetCookie("tempid","$tempid",0);
}else{
$tempid = $HTTP_COOKIE_VARS["tempid"];
}
// 새로 장바구니에 상품 추가
$basket_id = "tempid = '$tempid' and";
$qry_search = "SELECT * FROM fine_product_basket where $basket_id product_menuid = '$product_menuid'+ '+ ' and product_seqno = '$product_seqno' and product_ordernum = '+ 'X' order by seq_no desc";
$rst_search = mysql_query($qry_search);
$row_search = mysql_fetch_array($rst_search);
// echo "$qry_search <BR><BR>";
// $mode에 따른 작업처리 ----------------------------------------
switch($mode) {
case "update":
// 수량만 변경한(상품특성이 변하지 않은) 경우
$sql = "UPDATE fine_product_basket SET product_amount = $product_amount WHERE $basket_id seq_no='$product_seqno' AND product_ordernum = 'X'";
mysql_query($sql);
// echo "$sql <BR><BR>";
break;
case "del":
$sql = "DELETE FROM fine_product_basket WHERE $basket_id seq_no='$product_seqno' AND product_ordernum = 'X'";
mysql_query($sql);
// echo "$sql <BR><BR>";
break;
default :
if ($row_search){
// 상품 수량 추가
$amount_new = $row_search[product_amount] + $product_amount;
$sql = "update fine_product_basket set product_amount = $amount_new where $basket_id product_menuid = '$product_menuid' and product_seqno = '$product_seqno' and product_ordernum = 'X'";
mysql_query($sql);
// echo "$sql <BR><BR>";
} else {
// 상품 추가
$vdate = date("Ymd");
$sql = "INSERT INTO fine_product_basket
(seq_no, tempid, product_menuid, product_seqno, product_name, product_price, product_amount, product_ordernum, date)
VALUES ('', '$tempid', '$product_menuid', '$product_seqno', '$product_name', $product_price, '1', 'X', $vdate)";
mysql_query($sql);
// echo "$sql <BR><BR>";
}
break;
}
$qry = "SELECT * FROM fine_product_basket where $basket_id product_ordernum = 'X' order by seq_no desc";
$rst = mysql_query($qry);
// echo "$qry <BR><BR>";
function basket()
{
global $tempid,$rst,$product_menuid,$product_seqno,$form_num,$totalprice,$basket_menu_id;
$totalprice = 0;
$form_num = 0;
while($row = mysql_fetch_array($rst)){
$sumprice = $row[product_price] * $row[product_amount];
$form_num = $form_num+1;
echo "
<form name='form$form_num' action='$PHP_SELF' method='post'>
<input type=hidden name=product_seqno value="".$row[seq_no]."">
<input type=hidden name=product_menuid value="".$row[product_menuid]."">
<input type=hidden name=mode>
<TR align=center>
<TD><A HREF='product_detail.php?menu_id=$row[product_menuid]&seq_no=$row[product_seqno]'>$row[product_name]</A></TD>
<TD>".number_format($row[product_price])."</TD>
<TD>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td rowspan=2><input class='box' readonly name=product_amount size=2 value="".$row[product_amount]."" onChange="send(document.form$form_num,'update')" ></td>
<td width=20 align=center><a href=".javascriptfrm_up_qty(document.form$form_num,'update');"><img src="./images/up_icon.gif" width=15 height=13 border=0></a></td>
</tr>
<tr>
<td width=20 align=center><a href=".javascriptfrm_down_qty(document.form$form_num,'update');"><img src="./images/down_icon.gif" width=15 height=12 border=0></a></td>
</tr>
</table>
</TD>
<TD>".number_format($sumprice)."</TD>
<TD><a href=".javascriptsend(document.form$form_num,'del')"><FONT COLOR='red'><B>X</B></FONT></A></TD>
</TR>
</form>
";
$totalprice += $sumprice;
$basket_menu_id = $row[product_menuid];
}
if ($totalprice > 0) {
echo "
<TR height=30 bgcolor='D4E1EC'>
<TD colspan=3 align=right>Total : </TD>
<TD colspan=2 align=center>".number_format($totalprice)." 원</TD>
</TR>
";
}else{
echo "
<TR height=25>
<TD colspan=5 align=center>쇼핑하신 상품이 없습니다.</TD>
</TR>
";
}
}
$_INC_FILE = _BASE_DIR."/product_display/html/product_basket.html";
// 무조건 모든 파일에서 _MAIN_SKIN을 include 한다.
include _MAIN_SKIN;
?>
댓글 6
-
김준식
2005.08.02 13:49
-
승훈
2005.08.02 21:17
윗분말대로 하니까 안되는데요.ㅡㅡ;;;;;;;;;;;;;; 어찌해야 하는것인지;; -
승훈
2005.08.02 21:28
저걸 어디에다 넣어요?ㅡㅡ;
아무리 안바뀌는데. -
김연
2005.08.03 03:40
대충 이렇게 해보시면...;
위에 if($totalprice > 0) 이란부분이 아마두 주문한 금액이 있으면...이런 구문일건데요..
김준식님께서 말씀하신대로 해보세요..이렇게
if( ($totalprice > 0) && ($totalprice < 90000 ) ) {
$totalprice += 5000;
} elseif($totalprice > 9000) {
$totalprice = $totalprice;
}
이걸 위에 매칭시키셔서 하시면 될듯하네요.
if ($totalprice > 0) {
echo "<TR height=30 bgcolor='D4E1EC'>
<TD colspan=3 align=right>Total : </TD>
<TD colspan=2 align=center>".number_format($totalprice)." 원</TD>
</TR>";
}else{
echo "<TR height=25>
<TD colspan=5 align=center>쇼핑하신 상품이 없습니다.</TD>
</TR>";
}
위처럼 되어있는부분을 아래처럼 수정해서 쓰시면...
if( ($totalprice > 0) && ($totalprice < 90000 ) ) {
$totalprice += 5000;
echo "<TR height=30 bgcolor='D4E1EC'>
<TD colspan=3 align=right>Total : </TD>
<TD colspan=2 align=center>".number_format($totalprice)." 원</TD>
</TR>";
} elseif($totalprice > 9000) {
$totalprice = $totalprice;
echo "<TR height=30 bgcolor='D4E1EC'>
<TD colspan=3 align=right>Total : </TD>
<TD colspan=2 align=center>".number_format($totalprice)." 원</TD>
</TR>";
} else {
echo "<TR height=25>
<TD colspan=5 align=center>쇼핑하신 상품이 없습니다.</TD>
</TR>";
}
저두 초보라서 ^^; -
김연
2005.08.03 03:42
중간에 9000 -> 90000 이겠네요...ㅋ -
김준식
2005.08.03 09:41
if ($totalprice > 0) {
if ($totalprice < 90000)
$totalprice += 5000;
echo "
<TR height=30 bgcolor='D4E1EC'+ '+ '>
<TD colspan=3 align=right>Total : </TD>
<TD colspan=2 align=center>".number_format($totalprice)." 원</TD>
</TR>
";
}
else {
echo "
<TR height=25>
<TD colspan=5 align=center>쇼핑하신 상품이 없습니다.</TD>
</TR>
";
}
}
$totalprice += 5000;