Assignment 1: Creating
an e-Commerce Web-site
Scenario:
The marketing director of a company selling
<<you choose the product>>
approaches you to help him design an e-commerce
website for his company. He asks you to design a
website that will display at least 5
different products to
the user, from which they can choose multiple
quantities of any combination of the
products. He asks you to perform a check to make
sure that the user entered valid quantities
and to then calculate the sales total, including
tax and shipping and handling costs.
After completing this
assignment, you should have learned the
following:
- Inventing and implementing
a complete information system (IS)
- Building a reasonable user interface
- Processing user input
- Managing information with data types
- Interpreting and following development
requirements
Note:
You will not need to provide the actual products;
you're just selling imaginary products. You may
also provide services.
The main requirements for
this assignment are the following:
- Use multidimensional arrays
(an array that holds other arrays) to display
items in a table.
- Use forms to process information.
- Allow users to select and process multiple
products/services.
Now think specifically of what
you will sell or the services you wish to
provide. For example, "I will create an online
store for selling household robots." Register
your idea on the Assignment
1 signup page.
Getting Started: You can either
choose to create a project on your own that
meets the above requirements or you can follow
the step-by-step guide below to help you create
the project.
VERY
IMPORTANT: You must
comment all of your code! You may
even want to create a comment on what you are
trying to do before
you code. The comments are for explaining what
your code is used for in the program. This way
when we help you, we will know what is going on.
Not only because this is required, it will also
help you later on when working in group projects.
It may be hard for others to understand your code
without clear, detailed comments. Also
remember to include your name (as author), date,
and a brief description of what the code does at
the top of the file.
Part (A)
(1) Make an array for each
of your products and include the relevant
details for the product such as name, price,
description, etc. You will need to identify each
item you are offering by a unique name or
number.
Example :
If you were selling cell
phones, for each phone you would make an array
containing all that particular product's
information such as name/model number, maker
(e.g. Huawei, Samsung, Apple), description,
price, etc. Such as
$phone1 =
array(
'model' => 'Apple iPhone
XS',
'price' => 990.00
)
(2) Then you should make a
"master" products array to hold all of the
product arrays you created in step (1). In
other words, you will create an array of arrays
(a 'multi-dimensional' array).
Example :
Continuing with cell phone
example, you would make an array (say $allPhonesArray)
that holds all of the individual cell phone
arrays. You can use an indexed or associative
array:
$allPhonesArray = array($phone1, $phone2,
$phone3);
(3) Then, loop through the
master array with either for(), while(), or a
foreach() loop to display the descriptions of
the items.
Example :
The cell phone display may
look something like this (but, in your version,
you should include images of each product, as
you did in the mini-assignments):
Item # |
Cell Phone Model |
Price |
1 |
Samsung Galaxy Note 7
|
$700 |
2 |
iPhone XS
|
$990 |
3 |
HTC Desire 530
|
$150 |
4 |
Kyocera DuraForce XD
|
$399 |
5 |
LG V10 (Pre-owned)
|
$250 |
Part (B)
(1) Create an HTML form to
ask customers which items they wish to purchase
and process this form with PHP.
(2) Either use a combination
of an HTML file and PHP files, or use a single
"self processing form" that can both generate a
form and process it.
(3) The form displayed will
allow customers to select the item that they
want and the quantity they want in a text box.
You will also need a submit button on the form.
Example :
For the cell phone example,
we might change the display to allow for
customer input as shown below:
(4) You must use data
validation to ensure the customer entered valid
data. Note: if
valid data is not entered, display a specific
error message and direct the user to enter valid
data. And you must do this validation in PHP
code. You can not, for example, use a drop-down
list to constrain a user to enter only integer
quantities.
Example :
For the cell phone example,
you should make sure that the customer entered
valid quantities in the quantity boxes for each
item # (1 to 5) or anything at all. If the
customer entered -2.3 for item #1, display
"Please input a whole positive number for item
#1 quantity" and enable the customer to re-enter
number.
(5) Once the customer has
entered valid data, you will need to calculate
the total price that they have to pay and
display this information in an invoice. Don't
forget to include tax and shipping if necessary.
But specify that the tax and/or shipping are
unique to the order (don't just use a static
value). All output should be properly formatted
(e.g. if there was a dollar amount such as $2.39
it should have two decimal points and a dollar
sign).
Example :
INVOICE
Quantity
|
Cell Phone Model |
Price |
Extended Price |
2 |
Samsung Galaxy Note 7
|
$700 |
$1400 |
1 |
Kyocera DuraForce XD
|
$400 |
$400 |
|
|
Subtotal |
$1800 |
|
5% State sales tax |
Tax |
$90 |
|
3 items @ $5 per item |
Shipping |
$15 |
Thank
you
for
your
purchase!
Checklist:
After completing the
assignment make sure that you have addressed all
of the below. Note: Having all of these does not
guarantee an 'A' but you must have them.
- Registered idea on class
website.
- Meets stated main
requirements 1-3.
- Meets functional
requirements (displays products, allows user
to select product, allows user to select
quantities, displays invoice with sensible tax
and shipping charges along with totals.
- Commented--get in the habit
now! Put author's name and program
description as comments in files. Credit given
to original author when using "borrowed"
code.
- Used descriptive file names
and meaningful variable names.
- Employed good code
formatting.
- Defined and used arrays for
items.
- Created tables via array
data and loops.
- Good data validation (does
not allow invalid choices).
- Good user interface design
(easy to use and intuitive)
- No extra files or redundant
data.
- Correct output. No parse errors or warnings.
- Tested on the class
website, using the itm352student account,
saved in a folder with your name in an
Assignment1 sub-folder
ONE
LAST TIME: You must
comment all of your code (you may even want to
create a comment on what you are trying to do
before you code). The comments are for
explaining what your code is used for in the
program. That way when we help you, we will know
what is going on. Not only because this is
required, this will also help you later on when
working in group projects because it may be hard
for others to understand your code. Also
remember to put your name (as the author of
the code) and program description in the first
part of your comments.
Submission:
Upload completed
assignment to an Assignment1 folder within your
personal folder on itm-vm. ALSO
upload your php file(s) to the Assignment 1 area
on Laulima, and indicate there the URL of your
assignment on itm-vm. You need to do both
uploads!!!
|