$id = mysql_real_escape_string($user_custom); $obj = new cartDisplayer($id); $obj2 = new lib_giftPoint($id); } if (strcmp($res, "VERIFIED") == 0) { // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment if ($payment_status == 'Completed') { $query = "SELECT 'txn_id' FROM shop_ipn WHERE txn_id ='" . $txn_id . "'"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { if ($receiver_email == '*****@*****.**') { $totalcost = $obj->getCostTotal(); $shipcost = getShippingCost($obj->getItemTotal()); $taxcost = getTaxCost($totalcost); $reduce = 0; //default if ($obj2->isApplyDiscount($totalcost) == true) { $reduce = $obj2->getReduction() * -1; $taxcost = getTaxCost($totalcost - $obj2->getReduction()); } $finalcost = $totalcost + $shipcost + $taxcost + $reduce; if ($payment_amount < $finalcost * 1.005 + 0.1 and $payment_amount > $finalcost * 0.995 - 0.1 and $payment_currency == 'USD') { //reset gift point if it has been used: if ($obj2->isApplyDiscount($totalcost) == true) { $obj2->resetPoints(); } update_shopipn($id, $txn_id);
?> </tr> <?php if (isset($_SESSION["id"])) { $cartObj2->displayCart(); } ?> <?php if (isset($_SESSION["id"]) and $cartObj2->getItemTotal() != 0) { ?> <tr> <td colspan="7" class="cart_total"><span class="red">總額:</span></td> <td> $<?php echo $cartObj2->getCostTotal(); ?> </td> </tr> <tr> <td colspan="7" class="cart_total"></td> <td><input id="cart_save_button" type="submit" value="Save"></td> </tr> <?php } ?> </table></td> </tr> </table> </form>
<?php if (isset($_SESSION["id"])) { $cartObj = new cartDisplayer($_SESSION["id"]); $quantity = $cartObj->getItemTotal(); $costTotal = $cartObj->getCostTotal(); } else { $quantity = 0; $costTotal = 0; } ?> <div class="right_content"> <div class="cart"> <div class="title"><span class="title_icon"><img src="images/cart.gif" alt="" title="" /></span>My cart</div> <div class="home_cart_content"> <?php echo $quantity; ?> x items | <span class="red">TOTAL: $<?php echo $costTotal; ?> </span> </div> <a href="cart.php" class="view_cart">view cart</a> </div>