Alışveriş sepeti çıkış butonuna devre dışı bırakma - php

0 Cevap php

Ben noktaları / kredi kazanmak kullanıcılar giriş olduğu bir site içinde bir "alışveriş sepetine / sepeti" sayfa düzeni çalışıyorum. Onlar bu noktaları belli bir miktar kazanmak kez onlar daha sonra bir alışveriş sepeti gidip sadece bu noktaları ile ödeme yapabilirsiniz. (Para vb böylece yok paypal / çıkış / kargo / vergi katılıyor, el değiştirdiğinde)

Şimdiye kadar giriş var, çalışmak için arabası ve miktar özelliği değişikliği ürün eklemek, toplam tabloyu işaret ediyor.

What I am trying to do on this ‘view_cart.php’ page (code below) is to make the ‘Checkout’ link (submit_cart.php) disappear or be disabled if the user's points total is less than the total shopping cart price. Is there anyway I can do this on this script? The ‘You don’t have enough points to proceed to checkout’ prompt works if this is the case but if I can this checkout link to disappear that would be great.

My php knowledge is limited as I’m more of a front end designer but please feel free to offer any suggestions or changes of approach. Thanks!

<?php
$page_title = 'Your Rewards Shopping Cart';
include ('./includes/header.html');

if (!isset($_SESSION['users_id'])) {

   $url = 'http://' . $_SERVER['HTTP_HOST']
    . dirname($_SERVER['PHP_SELF']);
   if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
        $url = substr ($url, 0, -1); 
   }
   $url .= '/login.php'; 

ob_end_clean(); // Delete the buffer.
header("Location: $url"); 
exit(); // Quit the script.
}

$rwp = $_SESSION['reward_user_points']; 

$problem = FALSE; 

if (isset($_POST['submitted']))
   { 

foreach ($_POST['qty'] as $k => $v) {

$pid = (int) $k;
$qty = (int) $v;

if ( $qty == 0 ) { 
unset ($_SESSION['cart'][$pid]);
} elseif ( $qty > 0 ) { 
$_SESSION['cart'][$pid] ['quantity'] = $qty;
}

} // End of FOREACH.
} // End of SUBMITTED IF.

$empty = TRUE;
if (isset ($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $key =>$value) {
if (isset($value)) {
$empty = FALSE;
break; // Leave the loop.
}

} // End of FOREACH.
} // End of ISSET IF.

if (!$empty) {

require_once ('/MySQL/database.php');

$query = "SELECT users_id, reward_user_points FROM reward_points
            WHERE reward_points.users_id = users.users_id";
$result = mysql_query($query);  

$query = "SELECT products_id, products_name FROM categories, products
   WHERE categories.categories_id = products.categories_id AND products.products_id 
   IN (";foreach ($_SESSION['cart'] as $pid =>$value) {
$query .= $pid . ',';
}
$query = substr ($query, 0, -1) . ') ORDER BY categories.categories_name ASC';
$result = mysql_query($query);
?>

 <h1>Your Shopping Cart</h1>

    <div id="sidebar">
    <div id="statusbar">
    <p><span class="statusbar_highlight">Name:</span><br />
    <?php echo " {$_SESSION['users_first_name']} " . " {$_SESSION['users_surname']}<br> ";?></p>
    <p><span class="statusbar_highlight">Outlet:</span><br />
    <?php echo " {$_SESSION['users_outlet']} ";?></p>
    <p><span class="statusbar_highlight">Sales Number:</span><br />
    <?php echo " {$_SESSION['users_sales_no']} ";?></p>     
    <p><span class="statusbar_highlight">My Points:</span><br />
    <font size="+1"><?php echo " {$_SESSION['reward_user_points']} ";?></font></p> 
    </div>
    <br /><br /><br /><br /><br /><br /><br /><br />
    </div>

  <div id="maincontent_inner">
  <div id="maincontent_inner2"> 

<?php
echo '<table border="0" width="100%" cellspacing="1" cellpadding="5" align="center">
<tr class="top">
<td align="left" width="46%"><b>Reward Product</b></td>
<td align="right" width="18%"><b>Price</b></td>
<td align="center" width="16%"><b>Qty</b></td>
<td align="right" width="20%"><b>Sub Total</b></td>
</tr>
<form action="view_cart.php" method="post">';

$total = 0; // Total cost of the order.

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

// Total and subtotals.
$subtotal = $_SESSION['cart'][$row
   ['products_id']]['quantity'] *
   $_SESSION['cart'][$row ['products_id']]['price'];
$total += $subtotal;

if ($rwp >= $total) {
    }   
    else {
    echo "You do not have enought points to proceed to checkout <br />";
    }

// Print the row.
echo " <tr>
<td align=\"left\">{$row['products_name']}</td>
<td align=\"right\">{$_SESSION['cart'][$row['products_id']] ['price']} pts</td>
<td align=\"center\"><input type=\"text\" size=\"3\"
   name=\"qty[{$row['products_id']}]\"
   value=\"{$_SESSION['cart'][$row['products_id']]['quantity']}\" /></td>
<td align=\"right\">" . number_format ($subtotal) . " pts</td>
</tr>\n";
} // End of the WHILE loop.

mysql_close($dbc); // Close the database connection.

// products the footer, close the table, and the form.
echo ' <tr class="even">
<td colspan="3" align="right"><b> TOTAL:<b></td>
<td align="right"><b>' . number_format ($total) . ' pts </b></td>
</tr>
</table>
<br />
<div align="center"><input type="submit" name="submit"
   value="Update" />
<input type="hidden" name="submitted"value="TRUE" />
</form><br /><br /></div>
<p><a href="browse_rewards.php"><img src="images/but_continue.png" /></a></p>
<p><a href="submit_cart.php"><img src="images/but_checkout.png" /></a></p>';

} else {
echo '<h1>Shopping Cart</h1><p>Your cart is currently empty.</p>
<p><a href="browse_rewards.php"><img src="images/but_continue.png" /></a></p>
<div id="maincontent_inner">
<div id="maincontent_inner2"> ';
}

?>
<br />
<p>
<span class="extras"><strong>Please Note the following:</strong><br />
1. To delete any item off your cart, simply type in '0' and click 'Update'<br />
2. To add in more than one item, simply click the desired amount and click 'Update'<br />
3. Your cart will be emptied upon logging out of your session<br />
</span></p>

</div>
</div>
</div>
</div>


<?php
include ('./includes/footer.html');
?>

0 Cevap