| |
This file contains information and installation instructions for MyCart, a
shopping cart designed for MySQL and PHP.
These instructions are for MyCart version 1999.10.27
MyCart was designed by Christopher Ostmo of AppIdeas.com.
Feel free to use and modify these scripts to suit your needs. All that I
ask is that you keep all "Created by..." or "Designed by..." type markings
in their places, and please let me know what you think.
MyCart has been tested using PHP3 and MySQL 3.22.xx. These scripts should
work for other databases with little or no modification.
If you need help with MySQL, PHP or site design, AppIdeas.com technicians are
available for fee-based consultation.
Technical support for MyCart can be obtained by subscribing to AppIdeas.com's
PHP and MySQL mailing list. To do so, go to the web address:
http://open.appideas.com/support/
For a list of important changes in this version, consult the CHANGE file.
INSTALLATION & SETUP
Step 1 - Unpack the distribution.
If you are reading this message, then you have probably already completed
step one. If you need help unpacking these files, consult the Unix man
pages (type "man gzip" or "man tar" at the command propmpt) or Windows
WinZip help files.
When you unpack this distribution, it will create a directory called
"Cart" in the current directory. I unpacked the distribution in our web
server's root directory, so people can access MyCart at:
http://my.domain.com/Cart/
You don't have to do this, but it may simplify the rest of the setup if
you do.
When you unpack the distribution, several files will be in the top level
directory and in one subdirectory called "admin." As it's name implies,
the "admin" directory is for administrative functions. In case your
distribution does not unpack properly, here is where the files belong.
In the Cart root directory:
- CHANGE
- Cart.php
- README
- addCart.php
- addQuantity.php
- addQuantityResponse.php
- checkout.php
- description.php
- emptyCart.php
- index.php
- items.php
- order.php
- receipt.php
- removeItem.php
- userInfo.php
- viewCart.php
And in the /admin directory:
- addCategory.php
- addCategoryResponse.php
- addItem.php
- addItemResponse.php
- addPicture.php
- index.php
- receipt.php
- removeCategory.php
- removeCategory2.php
- removeCategoryResponse.php
- removeItem.php
- removeItem2.php
- removeItemResponse.php
- searchReceipts.php
- searchReceiptsResponse.php
- updateItem.php
- updateItem2.php
- updateItemResponse.php
- upload.php
- uploadItem.php
Step 2 - Setup MySQL
I created one database with 7 tables. You can setup the database and
tables as you see fit, but if you use my example, it will require less
modification of the scripts. This example assumes that you have access to
the Unix command prompt to manipulate MySQL. You can also follow these
instructions fairly closely if you have access to a MySQL User Interface.
The database name is a variable and can be changed easily, so you can call
it whatever you would like. The table names are not as easy to change,
so I would stick to the names given in this example. In this example, I
called the database "Cart."
-Create the database:
mysqladmin create Cart
-Connect to the database and create the tables:
mysql
connect Cart
CREATE TABLE Buyers (
Name VARCHAR(100) NOT NULL,
Address1 VARCHAR(100) NOT NULL,
Address2 VARCHAR(100) NOT NULL,
City VARCHAR(100) NOT NULL,
State CHAR(2) NOT NULL,
Zip VARCHAR(20) NOT NULL,
Email VARCHAR(100) NOT NULL,
DayPhone VARCHAR(100) NOT NULL,
EvePhone VARCHAR(100) NOT NULL,
Contact INT(1) NOT NULL,
PayMethod VARCHAR(100) NOT NULL,
CCType VARCHAR(100) NOT NULL,
CCNum VARCHAR(100) NOT NULL,
CCExpire VARCHAR(100) NOT NULL,
OrderTotal DECIMAL(8,2) NOT NULL,
Date VARCHAR(100) NOT NULL,
OrderNumber BIGINT NOT NULL,
UserID VARCHAR(100) NOT NULL,
BuyerID BIGINT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (BuyerID)
);
CREATE TABLE CartItems (
UserID VARCHAR(100) NOT NULL,
ItemID VARCHAR(25) NOT NULL,
ItemQuantity INT(4) NOT NULL,
Date VARCHAR(100) NOT NULL,
CartItemsID BIGINT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (CartItemsID)
);
CREATE TABLE Category (
Category VARCHAR(100) NOT NULL,
CategoryID BIGINT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (CategoryID)
);
CREATE TABLE Items (
ItemSKU VARCHAR(25) NOT NULL,
ItemName VARCHAR(100) NOT NULL,
ItemDescription MEDIUMTEXT NOT NULL,
ItemCost DECIMAL(7,2) NOT NULL,
Category BIGINT NOT NULL,
ShippingCost DECIMAL(6,2) NOT NULL,
ItemID BIGINT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (ItemID)
);
CREATE TABLE Orders (
BuyerID BIGINT NOT NULL,
UserID VARCHAR(100) NOT NULL,
Date VARCHAR(100) NOT NULL,
OrderTotal DECIMAL(8,2) NOT NULL,
OrderNumber BIGINT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (OrderNumber)
);
CREATE TABLE Receipts (
BuyerID BIGINT NOT NULL,
UserID VARCHAR(100) NOT NULL,
OrderNumber BIGINT NOT NULL,
Date VARCHAR(100) NOT NULL,
ItemID BIGINT NOT NULL,
ItemSKU VARCHAR(25) NOT NULL,
ItemName VARCHAR(100) NOT NULL,
ItemCost DECIMAL(7,2) NOT NULL,
ShippingCost DECIMAL(6,2) NOT NULL,
ItemQuantity INT NOT NULL,
TotalCost DECIMAL(8,2) NOT NULL
);
CREATE TABLE Users (
User VARCHAR(100) NOT NULL,
Date INT(4) NOT NULL
);
Step 3 - Setup your php3_include_path
These scripts use a require statement that calls "Cart.php" In order for
this to work properly, you need to set PHP's include path so that it will
look in the Cart root directory. If your web server allows .htaccess
files to override Apache config file settings, then place a file called
.htaccess in you Cart root directory with the following line:
php3_include_path /path/to/Cart
If you cannot override Apache config file settings through .htaccess, then
you can place the above line in your web server's
directive in the Apache config files.
For PHP4, this may be changed to "php4_include_path" or "php_include_path"
- I'm not sure as PHP4 is still in beta at the time of this writing.
If you use a web server other than Apache, you will need to check your web
server's documentation for details.
If you can't do either of those, create a PHP script which contains the
following line:
<? phpinfo(); ?>
When you view that script in a web browser, you will see a directive
called "include_path" in the Configuration table. Place the Cart.php file
in one of the directories listed.
If you can't make anything work, change the require(...) statement in the
files of the admin directory to read:
require("../Cart.php");
Step 4 - Modify Cart.php
Replace the variables in the first section to reflect information about
how to contact your company. The $NoShipping variable is the text
string to send to the customer when you have not specified a shipping
cost. NOTE: The "$Email" variable must be defined and valid! This is the
address to which orders are mailed.
Replace the variables in the second section with your proper database Host
Name, Username, Password and Database Name ("Cart" in the above example).
Replace the variables in the third section with the absolute (Unix) path
and relative (to web users) path to your MyCart scripts. Do not end
either of these with a forward slash ( / ). You need to precede the
$Relative variable with a forward slash.
Step 5 - Create the images directory
Create a directory off of your Cart directory called "images"
Make the images directory owned by the same user and group as httpd
(usually nobody:wheel). Make this directory user and group readable,
writable and executable and make it world readable and executable.
Unix users will use the commands:
chown nobody:wheel images
chmod 775 images
This gives the images directory the following permissions:
drwxrwxr-x nobody wheel images
Step 6 - Setup your catalog
Go to the Cart/admin directory and add some product categories. Once you
have done this, you can add individual products.
Step 7 - Protect your admin directory
You should have some sort of protection (preferrably password protection)
on your admin directory. Consult your web server documentation for
instructions.
SPECIAL NOTES
MyCart has been fairly well tested under a lot of circumstances. Here are
a few things to keep in mind:
-These files use an extension of .php for future compatibility with the
PHP4 "standard" file names. If your web server does not support the .php
extension as valid PHP scripts, you will need to either instruct it to do
so (this can be accomplished in Apache by adding an "AddType" directive in
your Apache config files or .htaccess file - see your web server's and
PHP's documentation), or you will need to rename the scripts with valid
PHP script extensions.
-When users add an item to their cart, increase the quantity of an item in
their cart, empty their cart, or remove an item from their cart, they are
automatically forwarded to the viewCart.php page. You can instead
forward them to another page (like the first page of your catalog) by
editing the ("Location:...") tag in the addCart.php,
addQuantityResponse.php, emptyCart.php and removeItem.php pages.
-If you need to upload pictures that are larger than 200K (pray for the
customers that have to wait for them to download!), you can modify the
updateItemResponse.php script in the admin directory. You need to
increase the MAX_FILE_SIZE value.
-I purposefully kept MyCart pretty bland and unformatted. This should
make it easier for an individual user to customize it to suit his or her
needs. Please work around the code that I have created and create an
interface that will be aesthetically pleasing to your customers.
-If you need to store receipts and user information for more than one
year, modify the index.php file in the admin directory. Immediately After
the line that reads:
$pieces=explode(":",$Da);
Add:
$pieces[0]=bcadd($pieces[0],4);
The "4" will cause information to be stored for 5 years. Change the "4"
above to one less than the desired number of years to store the
information.
LEGALESE
These scripts were created and made freely available to further the
knowledge and use of PHP and MySQL. These scripts are provided "as-is"
and carry no warranty, either stated or implied. Rosenet and it's
employees take no responsibility for any damages (real or imagined) that
occur as a result of using these scripts or instructions . By using these
scripts, you agree to be completely responsible for any damages to your
computer system(s) or network(s).
These scripts are available as free software. Feel free to use and modify
them as you deem necessary. If you wish to distribute these scripts,
please ask for permission first. If you plan to distribute these scripts
or any derivative thereof in a commercial package (one for which you
receive monetary compensation), please consider helping us to further our
efforts by offering to share a portion of the proceeds.
FUTURE AND SUPPORT
If you need to contact me with any questions, bug reports or feature
requests, sign up for the mailing list.
The fact that I have a job and a family (both of which I would like to
keep) means that I simply don't have time to answer many technical support
questions. Please be kind to me and direct technical support questions to
the mailing list mentioned near the top of this file.
http://open.appideas.com/ - AppIdeas.com's MySQL Utilities and Future
Versions of This Software
This file, these scripts and "MyCart" are
Copyright 1998-2001, AppIdeas.com.
|




 |