PHP
  Home arrow PHP arrow Page 10 - Building an E-Commerce Site Part 3: Ca...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building an E-Commerce Site Part 3: Catalogs and Shopping Carts
By: Ying Zhang
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 46
    2000-06-08

    Table of Contents:
  • Building an E-Commerce Site Part 3: Catalogs and Shopping Carts
  • Assumptions and Requirements
  • Overview of The Process
  • MyMarket Shopping Experience
  • The Product Catalog
  • The Shopping Cart
  • Payment Processing
  • Step 1: Database Changes
  • Step 2: Extracting the New Scripts
  • Step 3: General Script Changes from Tutorial 2
  • Step 4: New Shopping Scripts
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building an E-Commerce Site Part 3: Catalogs and Shopping Carts - Step 3: General Script Changes from Tutorial 2


    (Page 10 of 12 )

    We’ve made a few changes since tutorial 2. A new library was added, a bunch of shopping related scripts, and more.

    application.php

    Now loads up the shopping cart library (lib/cart.php) and initializes the shopping cart if it hasn't already been initialized.

    index.php

    The index page now lists the on-special items on the right of the screen. You mark an item as being on special from the administrative product manager screens (which have also been modified to accomodate this new feature).

    admin/products.php

    The products administration screen has been modified to handle the on-special flag. This is the first time we are dealing with checkboxes, they are wierd to deal with when processing HTML forms because they behave a bit differently from the other form input types. They are defined when checked, and undefined otherwise. This forces your scripts to check for the existence of form variable instead of checking for it's value.

    admin/orders.php

    This is a new administrative function to show the orders that have taken place on the system. It is a simple listings of the orders with the ability to see the order details.

    admin/users.php

    Fixed a bug from part 2, every user you created got the password $password due to quoting problems. Thanks to the people who pointed it out :)

    lib/cart.php

    This file contains the declaration of the Cart class. If you are new to objects in PHP, take a moment to look at how it is written. The session variable $SESSION["cart"] is an instance of this Cart class.

    lib/mymarket.php

    Added some new functions:

    • err2()
      Like the original err() function, except it prints the market >> instead of <<.
    • get_category_tree()
      Returns the category navigation tree as a string.
    • print_category_tree()
      Calls get_category_tree() and prints the result.
    • get_cart_items()
      Returns a handler ($qid) of a database query with the id, name, and unit price of all the items in the shopping cart.
    • chop_ccnum()
      Returns parts of a credit card number so that it is safe to display without giving out the customer's credit card number.
    • save_orderinfo()
      Used in the order confirmation screen, this function saves the customer's order information (which includes contact information and credit card information) into the session temporarily.
    • load_orderinfo()
      The counter part to save_orderinfo(), this will retrieve the customer's order information from the session.
    • clear_orderinfo()
      Clears out the customer order information saved in the session, this is called once the orderinfo was successfully retrieved by load_orderinfo(). Together, these three functions are responsible for passing sensitive order information between the purchase and payment processing scripts.
    • Like the original err() function, except it prints the market instead of .Returns the category navigation tree as a string.Calls get_category_tree() and prints the result.Returns a handler () of a database query with the id, name, and unit price of all the items in the shopping cart.Returns parts of a credit card number so that it is safe to display without giving out the customer's credit card number.Used in the order confirmation screen, this function saves the customer's order information (which includes contact information and credit card information) into the session temporarily.The counter part to save_orderinfo(), this will retrieve the customer's order information from the session.Clears out the customer order information saved in the session, this is called once the orderinfo was successfully retrieved by load_orderinfo(). Together, these three functions are responsible for passing sensitive order information between the purchase and payment processing scripts.

    templates/header.php

    The standard header template has been modified to show the shopping cart summary. So throughout the site, the user will always know their shopping cart summary.

    More PHP Articles
    More By Ying Zhang


     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT