Code: Select all
<?php
session_start();
$depth = "0";
if(isset($_GET['depth']))
{
$depth = $_GET['depth'];
$_SESSION['depth']=$depth;
}
else
{
$depth=$_SESSION['depth'];
}Moderator: General Moderators
Code: Select all
<?php
session_start();
$depth = "0";
if(isset($_GET['depth']))
{
$depth = $_GET['depth'];
$_SESSION['depth']=$depth;
}
else
{
$depth=$_SESSION['depth'];
}Code: Select all
$depth = "0";
if(isset($_GET['depth']))
{
$depth = $_GET['depth'];
$_SESSION['depth']=$depth;
}
else if (isset($_SESSION['depth']))
{
$depth=$_SESSION['depth'];
}Code: Select all
<?php
session_start();
$depth = "0";
if(isset($_GET['depth']))
{
$depth = $_GET['depth'];
$_SESSION['depth']=$depth;
}
else if (isset($_SESSION['depth']))
{
$depth=$_SESSION['depth'];
}
$length = "0";
if(isset($_GET['length']))
{
$length = $_GET['length'];
$_SESSION['length']=$length;
}
else if (isset($_SESSION['length']))
{
$length=$_SESSION['length'];
}
$thickness = "0";
if(isset($_GET['thickness']))
{
$thickness = $_GET['thickness'];
$_SESSION['thickness']=$thickness;
}
else if (isset($_SESSION['thickness']))
{
$thickness=$_SESSION['thickness'];
}
include "dbconn.php";
if ($depth > "0" && $length > "0" && $thickness > "0")
{
$query = "SELECT price, productid, sku FROM products WHERE depth = '$depth' AND length = '$length' AND thickness = '$thickness'";
$result = $pdo->prepare($query);
$result->execute(array(':depth' => "%{$depth}%",':length' => "%{$length}%",':thickness' => "%{$thickness}%"));
$num_rows = $result->rowCount();
if ($num_rows == 0)
{
echo "<br/>Sorry we don't have your size available.";
}
else
{
echo "<div class='presearchbox' >";
while ($row = $result->fetch(PDO::FETCH_OBJ))
{
echo "<div class='premier_price'>£$row->price</div>
<a href='/premiercart&productid=$row->productid' class='premier_cart'>Add to Cart</a>";
}
echo "</div>";
}
}
mysql_close($sqlconn);
?>Code: Select all
$query = "SELECT price, productid, sku FROM products WHERE depth =:depth AND length =:length AND thickness =:thickness AND sku =:sku";
$result = $pdo->prepare($query);
$result->execute(array(':depth' => $depth,':length' => $length,':thickness' => $thickness,':sku' => $sku));
$num_rows = $result->rowCount();
if ($num_rows == 0)
{
echo "asdfsadf, $depth, $length, $thickness";
}
else
{
echo "<div class='presearchbox' >";
while ($row = $result->fetch(PDO::FETCH_OBJ))
{
echo "<div class='premier_price'>£$row->price</div>
<a href='/premiercart&productid=$row->productid' class='premier_cart'>Add to Cart</a>";
}
echo "</div>";
}I have built carts that session and database. Using the session is simpler because there is little housekeeping involved. Carts using a database table are useful if you want the user to be able to save the contents of the cart between sessions.simonmlewis wrote:Right I think I have this pinned down now.
The next job is to create an actual Cart.
We've never needed to do this as we always use third parties. But their current site has it on the cart, via SSL.
The only way I can see how it would work, is via a Database "cart" table, that does it via a Session ID number. So if you do login, it then overrides the Session ID with the User ID.
That way you can add all the items you want, all assigning to that one Sess/User ID.
The payment services provide both code and instructions for checkout.simonmlewis wrote:But how do you then pass that information over to PayPal or Sage, and see the products you have ordered, on said third parties - I'm really stuck there.
I assume they are waiting for content of variables, but I'm lost here.
Code: Select all
<form action="https://www.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="youremail@mail.com">
<input type="hidden" name="currency_code" value="US">
<input type="hidden" name="item_name_1" value="beach ball">
<input type="hidden" name="amount_1" value="15">
<input type="hidden" name="item_name_2" value="towel">
<input type="hidden" name="amount_2" value="20">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>Use their cart ID or some custom order number that you've set beforehand. Send that along with the PayPal request, either as order number or as a custom variable (literally input name=custom) and then retrieve the items ordered when you get the PayPal response.Not sure though, how, when they return to the main site, the site can trigger the items as purchased on the web site.