Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_SESSION['_myCart']))
- $_SESSION['_myCart']=array();
- if(sizeof($_SESSION['_myCart'])==0)
- {
- echo 'Your shopping cart is empty';
- }
- else
- {
- $checkoutbtn .='
- <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
- <input type="hidden" name="cmd" value="_cart">
- <input type="hidden" name="upload" value="1">
- <input type="hidden" name="business" value="[email protected]">';
- echo ' <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th>Remove</th>
- <th>Image</th>
- <th>Product ID</th>
- <th>Product Name</th>
- <th>Model</th>
- <th>Quantity</th>
- <th>Unit Price</th>
- <th>Total</th>
- </tr>
- </thead>
- ';
- $totalCart=0;
- foreach($_SESSION['_myCart'] as $id=>$qty)
- {
- $rsCheckPrd=mysql_query("SELECT * FROM tbl_product WHERE productID=".$id) or die(mysql_error());
- if ($prd = mysql_fetch_assoc($rsCheckPrd)) {
- $productID = $prd["productID"];
- $brand = $prd["brand"];
- $model = $prd["model"];
- $price = $prd["price"];
- $prodimg = $prd["thumbimg"];
- $checkoutbtn .='
- <INPUT TYPE="hidden" NAME="item_name_x" VALUE="'.$model.'">
- <INPUT TYPE="hidden" NAME="item_number_x" VALUE="'.$productID.'">
- <INPUT TYPE="hidden" NAME="amount_x" VALUE="'.$price.'">
- <INPUT TYPE="hidden" NAME="quantity_x" VALUE="'.$qty.'">';
- $total=$prd['price']*$qty;
- echo'<tr>
- <tbody>
- <td class=""><a href="cartdelete.php?id='.$productID.'"> <button class="btn btn-primary">Delete </button> </a></td>
- <td class="muted center_text"><img src="'.$prodimg.'"></td>
- <td>'.$productID.'</td>
- <td>'.$brand.'</td>
- <td>'.$model.'</td>
- <td><form><input type="text" id="id_input_qty_'.$productID.'" value="'.$qty.'" class="input-mini"> <input type="button" class="btn btn-primary" onclick="javascript:validQuantity('.$productID.');" value="Update"/> </a> </td>
- <td>₱'.$price.'</td>
- <td>₱ '.$total.'</td>
- </tr>';
- $totalCart+=$total;
- }
- else
- unset($_SESSION['_myCart'][$id]);
- }
- $checkoutbtn .='
- <INPUT TYPE="hidden" NAME="notify_url" VALUE="www.@@@@.com/ecomm/paypalIPN.php">
- <INPUT TYPE="hidden" NAME="return" VALUE="www.@@@@.com/ecomm/ordersuccess.php">
- <INPUT TYPE="hidden" NAME="rm" VALUE="2">
- <INPUT TYPE="hidden" NAME="cbt" VALUE="Return to the Store">
- <INPUT TYPE="hidden" NAME="cancel_return" VALUE="www.@@@@@.com/ecomm/ordercancel.php">
- <INPUT TYPE="hidden" NAME="lc" VALUE="US">
- <INPUT TYPE="hidden" NAME="currency_code" VALUE="PHP">
- <button class="btn btn-primary" type="submit">Checkout</button>
- </form>
- ';
- echo '
- <tr>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td><strong>₱'.$totalCart.'</strong></td>
- </tr>
- </tbody>
- </table>';
- }
- ?>
- <div class="row">
- <div class="span5">
- <button class="btn btn-primary" type="submit">Continue shopping</button>
- </div>
- <div class="span7">
- <?php echo $checkoutbtn; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement