This topic is locked

Related Products

3/28/2008 5:31:00 PM
Shopping Cart Template general questions
M
moganowski author

Can a relational table be made from the Inventory table so that a product and it's various parts options can be selected on one screen? Am envisioning a type of motor, with several categories of parts, each containing multiple choices with separated prices.
Thanks a lot,

Marcia

J
Jane 4/1/2008

Here are some tips:

  1. create another table with parts options and setup master-detail relationships between inventory and this new table.
  2. add custom event on the list page of this new table.

    Here is a sample:
    echo "<A onclick=\"frmAdmin.a.value='update'; frmAdmin.submit(); return false;\" href=\"TableName_list.htm#\">Add to cart</A>";



And add some code to the BeforeDelete event:

//delete records

if(@$_POST["a"]=="delete")

return true;
//add to cart

//select all additional options from table and save it in the $_SESSION variables or in another temp table

global $conn,$strTableName;

$str = "select * from tablename where ".$where;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
for ($i=0; $i<count($data);$i++)

$_SESSION[$i."_optionid"] = $data["OptionID"];
//redirect to inventory page and add record to the shopping cart

header("Location: inventory_list.php?item=".$_SESSION[$strTableName."_masterkey1"]);

exit();

return false;


To show selected options on the shopping_cart list page use saved values from $_SESSION variables or in the temp table. Also you can increase shopping_cart table and save selected options in this table in the ListOnLoad event for inventory table.