public function applyDiscountHTML($totalCost)
 {
     $xStatus = new lib_userStatus();
     $reduction = $this->getReduction();
     $i = 0;
     $query = "SELECT RETAIL, quantity\n\t\tFROM bz_bookstore, carts\n\t\tWHERE carts.id ={$this->id} AND carts.pid = UPC";
     $result = mysql_query($query);
     if ($this->isApplyDiscount($totalCost)) {
         while ($row = mysql_fetch_assoc($result)) {
             $i++;
             $price = $row["RETAIL"];
             $quan = $row["quantity"];
             $subTotal = $xStatus->price($price * $quan);
             if ($reduction < $subTotal) {
                 echo '<input type="hidden" name="discount_amount_' . $i . '" value="' . $reduction . '">';
                 $reduction = 0;
             } else {
                 echo '<input type="hidden" name="discount_amount_' . $i . '" value="' . ($subTotal - 0.01) . '">';
                 $reduction -= $subTotal - 0.01;
             }
         }
     }
 }
Exemple #2
0
//member info:
$query = "\n\tSELECT * \n\tFROM membership_ipn\n\tWHERE user_id = {$id}\n\t";
$result = mysql_query($query);
if (mysql_num_rows($result) == 1) {
    $hasData = true;
    $row = mysql_fetch_assoc($result);
    $realname = $row["real_name"];
    $phone = $row["phone"];
    $yy = $row["birth_year"];
    $mm = $row["birth_month"];
    $dd = $row["birth_day"];
} else {
    $hasData = false;
    $realname = $phone = $yy = $mm = $dd = "没资料";
}
$yStatus = new lib_userStatus($id);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
	#main{  
		margin-top:20px;
		margin-left:50px;
		margin-right:50px;
		font-size:15px;
	     }
	#mainform{
		  height:500px;
    public function displayPaypalForm()
    {
        $xStatus = new lib_userStatus();
        ?>
				<form action="https://www.paypal.com/cgi-bin/webscr" method="post" class="paypal_btn"> 
				<input type="hidden" value="utf-8" name="charset"> 
				<input type="hidden" name="cmd" value="_cart"> 
				<input type="hidden" name="upload" value="1"> 
				<input type="hidden" name="business" value="*****@*****.**">
				<input type="hidden" name="currency_code" value="US"> 
			<?php 
        for ($i = 0; $i < count($this->itemArr); $i++) {
            ?>
				<input type="hidden" name="item_name_<?php 
            echo $i + 1;
            ?>
" value="<?php 
            echo $this->itemArr[$i]["PROD_NAME"];
            ?>
"> 
				<input type="hidden" name="amount_<?php 
            echo $i + 1;
            ?>
" value="<?php 
            echo $xStatus->price($this->itemArr[$i]["RETAIL"]);
            ?>
"> 
				<input type="hidden" name="quantity_<?php 
            echo $i + 1;
            ?>
" value="<?php 
            echo $this->itemArr[$i]["quantity"];
            ?>
"> 
			<?php 
        }
        $pointObj = new lib_giftPoint($this->id);
        $pointObj->applyDiscountHTML($this->getCostTotal());
        ?>

			<input TYPE="hidden" name="return" value="http://jewel.ziggyism.com/test/BZcomic/confirm2.php">
			<input TYPE="hidden" name="cancel_return" value="http://jewel.ziggyism.com/test/BZcomic/index.php">
			<input type="hidden" name="notify_url" value="http://jewel.ziggyism.com/test/BZcomic/ipn/shop_ipn.php"> 
			<input type="hidden" name="custom" value="<?php 
        echo $this->id;
        ?>
">
				<input type="image" src="images/paypal_btn.jpg" width="150" height="30" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> 
				</form>
			<?php 
    }
    public function displayLISTPage()
    {
        $xStatus = new lib_userStatus();
        if ($this->itemNum == 0) {
            echo "<h3>對不起, 沒有結果! 暫時沒有這樣的書.</h3>";
        } else {
            $lowerBound = ($this->curPage - 1) * $this->itemDisplayPerPage;
            $upperBound = $this->curPage * $this->itemDisplayPerPage <= $this->itemNum ? $this->curPage * $this->itemDisplayPerPage : $this->itemNum;
            for ($i = $lowerBound; $i < $upperBound; $i++) {
                ?>
		
		<li>
		<span class="bookTitle">&nbsp;</span>
		<span class="bookUnit"><a title="哥布林之夜" href="detail.php?id=<?php 
                echo $this->itemArr[$i]["ID"];
                ?>
" target="_blank"><img alt="哥布林之夜" src="<?php 
                echo $this->itemArr[$i]["imgLink"];
                ?>
" /></a>
		</span>
		<span class="li_detail">
			<p style="padding-top:0px;margin-top:0px;"><b><a class="book" href="detail.php?id=<?php 
                echo $this->itemArr[$i]["ID"];
                ?>
" style="font-size:25px; padding-top:0px;margin-top:0px;text-decoration:underline;color:#3A79F0"><?php 
                echo $this->itemArr[$i]["PROD_NAME"];
                ?>
</a></b></p>
			<p>定價:<span><?php 
                echo $this->itemArr[$i]["RETAIL"];
                ?>
美元</span> &nbsp;&nbsp;&nbsp;(貴賓會員優惠價:<span><?php 
                echo $xStatus->printPriceDescript();
                ?>
</span>:<span><?php 
                echo $xStatus->price($this->itemArr[$i]["RETAIL"]);
                ?>
</span>美元)</p>
			<p>庫存: <span><?php 
                echo $this->itemArr[$i]["QTY_HND"];
                ?>
</span> 本 (如果沒庫存表明到貨時間)</p>
			<form class="cart_form">  
			<p>
				你要購買的數量: <input id="buy_amount"  name="quantity" type="text" value="1" size="2" maxlength="2"/>&nbsp;&nbsp;&nbsp; 本
			</p>
			<p>&nbsp;</p>
			<p class="story_summary"><?php 
                echo $this->itemArr[$i]["detail"];
                ?>
			</p>
			<p style="text-align:right;"><a href="detail.php?id=<?php 
                echo $this->itemArr[$i]["ID"];
                ?>
"> <更多...> </a></p>
			<span class="top_right_btn">
				<img class="bookImgBtn" id="submit" pid ="<?php 
                echo $this->itemArr[$i]["UPC"];
                ?>
"  src="images/add_to_cart_btn.png" width="115" height="32" border="0" />
			</span>
			</form>
		</span>
		</li>
	
	<?php 
            }
        }
    }