PHP 5 E-commerce Development

PHP 5 E-commerce Development
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Build a flexible e-commerce framework using PHP, which can be extended and modified for the purposes of any e-commerce site
  • Enable customer retention and more business by creating rich user experiences
  • Develop a suitable structure for your framework and create a registry to store core objects
  • Promote your e-commerce site using techniques with APIs such as Google Products or Amazon web services, SEO, marketing, and customer satisfaction

Book Details

Language : English
Paperback : 356 pages [ 235mm x 191mm ]
Release Date : January 2010
ISBN : 184719964X
ISBN 13 : 9781847199645
Author(s) : Michael Peacock
Topics and Technologies : All Books, Web Development, e-Commerce, Open Source, PHP

Table of Contents

Chapter 1: PHP e-commerce
Chapter 2: Planning our Framework
Chapter 3: Products and Categories
Chapter 4: Product Variations and User Uploads
Chapter 5: Enhancing the User Experience
Chapter 6: The Shopping Basket
Chapter 7: The Checkout and Order Process
Chapter 8: Shipping and Tax
Chapter 9: Discounts, Vouchers, and Referrals
Chapter 10: Checkout
Chapter 11: Taking Payment for Orders
Chapter 12: User Account Features
Chapter 13: Administration
Chapter 14: Deploying, Security, and Maintenance
Chapter 15: Marketing, SEO, and Customer Retention
Appendix A: Interacting with Web Services
Appendix B: Downloadable Products
Appendix C: Cookbook
  • Chapter 1: PHP e-commerce
    • e-commerce: Who, what, where, why?
      • An overview of e-commerce
        • eBay
        • Amazon
        • Brick 'N Mortar stores
        • Service-based companies
      • Why use e-commerce?
    • Rolling out your own framework
      • Why PHP?
      • Why a framework?
      • When to use an existing package?
        • Existing products
      • A look at e-commerce sites
        • iStockphoto
        • WooThemes
        • eBay
        • Amazon
    • e-commerce: What does it need to do/have?
      • Products
      • Checkout process
      • General
    • Our framework: What is it going to do?
    • Our framework: Why is it going to do it?
      • Juniper Theatricals
    • Summary
  • Chapter 2: Planning our Framework
    • Designing a killer framework
      • Patterns
        • Model-View-Controller (MVC)
        • Registry
        • Singleton
      • Structure
    • Building a killer framework
      • Pattern implementation
        • MVC
        • Registry
        • Singleton
        • Registry objects
      • Routing requests
        • An alternative: With a router
        • Processing the incoming URL within our registry object
        • index.php
        • .htaccess file
        • Configuration file
    • What about e-commerce?
      • An e-commerce registry?
    • Summary
  • Chapter 3: Products and Categories
    • What we need
      • Product information
      • Category information
      • Structuring content within our framework
        • Pages
        • Content
        • Versioning
    • Building products, categories, and content functionality into our framework
      • Database
        • Content
        • Content types
        • Content versions
        • Products
        • Categories
      • Pages within our framework
        • Model
        • View
        • Controller
      • Products
        • Model
        • View
        • Controller
      • Categories
        • Model
        • View
        • Controller
      • Some thoughts
      • Product and category images
    • Routing products and categories
      • Featured products
    • Embedding products
    • Summary
  • Chapter 4: Product Variations and User Uploads
    • Giving users choice
      • Simple variants
        • How could this work?
      • Combinations of variants
        • How will this work?
        • High-level overview
        • Database structure
        • Template switching
        • Templates
        • A look back at simple variants
    • Giving users control
      • How to customize a product?
        • Uploads
        • Custom text
      • Maintaining uploads
        • Security considerations
      • Database changes
        • Extending our products table
      • Template switching
    • Shopping basket preparation
      • Stock control
      • Product variations
      • Product customizations
      • Basket templates
      • Product subtotals
    • Summary
  • Chapter 5: Enhancing the User Experience
    • Juniper Theatricals
    • The importance of user experience
    • Search
      • Finding products
        • Search box
        • Controlling searches with the products controller
        • Search results
        • Improving searches
      • Filtering products
        • Product attributes
        • Filter options
        • Processing filter requests
        • Displaying filtered products
        • Improving product filtering
    • Providing wish lists
      • Creating the structure
      • Saving wishes
        • Wish-list controller
        • Add to wish list
      • Viewing a wish list
        • Controller changes
        • Wish-list view
      • Purchases
        • Gift purchases
        • Self purchases
      • Improving the wish list
    • Recommendations
      • Related products
        • Controlling the related products
        • Viewing the related products
      • E-mail recommendations
    • Help! It's out of stock!
      • Detecting stock levels
        • Changing our controller
      • Out of stock: A new template bit
      • Tell me when it is back in stock please!
        • Stock alerts database table
        • More controller changes
      • It is back!
    • Giving power to customers
      • Product ratings
        • Saving a rating
        • Viewing ratings
      • Product reviews
        • Processing reviews/comments
        • Displaying reviews/comments
      • Combining the two?
    • Any other experience improvements to consider?
    • Summary
  • Chapter 6: The Shopping Basket
    • Shopping baskets
    • Our basket
      • Per-page basket
    • Considerations for our shopping basket
    • Creating a basket
      • When to build a user's basket
      • Basket database
    • Basket contents
      • Viewing the basket
        • checkBasket method
        • The controller
      • Adding products
        • An addProduct method
        • The controller
        • A note on etiquette
      • Adding customizable products
        • Changing our basket database
        • Viewing the basket
        • Changing the model
        • The controller
      • Adding product variants
        • A new database table
        • Model changes
        • The controller
      • Editing quantities
    • From visitor to a user
      • The transferToUser function
      • Performing the transfer
    • Cleaning the basket
      • Expired contents
    • Displaying the basket on every page
      • Functionality
    • Summary
  • Chapter 7: The Checkout and Order Process
    • Some examples
      • Amazon
        • Limitations
        • Useful features
      • eBay
        • Interesting points of note
        • Interesting points of note
    • The process
      • The basket
        • Voucher codes
        • Shipping method
        • An overview
      • Authentication
        • Why should we authenticate the user at this stage?
        • Login
        • Register
        • Do nothing
      • Delivery address
      • Payment method
        • Offline payment method
        • Off-site payment method
        • On-site payment method
      • Confirmation
      • Payment details
      • Payment made
      • Order processed
      • Other points of note
    • Summary
  • Chapter 8: Shipping and Tax
    • Shipping
      • Shipping methods
      • Shipping costs
        • Product-based shipping costs
        • Weight-based shipping costs
        • To think about: Location-based shipping costs
      • Shipping rules
        • Free shipping
        • Capped shipping
      • Tracking
      • Integrating shipping costs into the basket
        • Shipping methods and a default
        • Calculating shipping costs based on products
        • Calculating shipping costs based on product weights
        • Considering shipping rules, and adjusting prices accordingly
    • Tax
      • Separately calculating tax values
      • To think about: Location-based tax costs
    • A look at our basket now
    • Summary
  • Chapter 9: Discounts, Vouchers, and Referrals
    • Discount codes
      • Discount codes data
        • Discount codes database
      • Discount codes functionality
        • Reducing the number of codes available
    • Purchasable voucher codes
      • Existing functionality
        • Discount codes
        • Product variations
      • Required additional functionality
    • Referrals
      • Database changes
        • New table: Referrers
        • Changes
      • Functionality
        • Checkout process consideration
    • Summary
  • Chapter 10: Checkout
    • Order process review
    • Authentication
    • Delivery address
    • Payment method
    • Confirmation
      • Storing orders in the database
        • Orders table
        • Order statuses
        • Order items
        • Order item attributes
        • Payment methods
    • Summary
  • Chapter 11: Taking Payment for Orders
    • Taking payment
      • Our payment system
    • Taking payment online
      • PayPal
        • The payment button
        • Processing payment to update the order
      • Direct with a credit/debit card
        • Storing card details
        • Not storing card details
      • Other payment gateways
      • Payment gateway tips
    • Taking payment offline
    • Summary
  • Chapter 12: User Account Features
    • User account area
    • Changing details
      • Changing password
      • Changing default delivery address
    • Viewing orders
      • Listing orders
        • Query
      • Viewing an order
        • Order model
      • Cancelling an order
        • Order model additions
        • Controller code
    • Expansion
    • Summary
  • Chapter 13: Administration
    • Dashboard
    • Products and categories
      • Products
        • Creating a product
        • Editing a product
      • Categories
        • Creating a category
        • Editing a category
        • Deleting a category
    • Orders and customers
      • Orders
        • Updating an order
        • Dispatch note
        • Refunds
      • Customers area
        • Listing customers
        • A customer's orders
    • Miscellaneous
      • Shipping
        • Creating a shipping method
      • Voucher codes
        • Creating a voucher code
    • Summary
  • Chapter 14: Deploying, Security, and Maintenance
    • Deploying
      • Hosting accounts and domain names
        • Hosting providers
        • Domain name registrars
      • Manual deployment
        • Setting up the database
        • Uploading our store
        • Settings
      • Automated deployment
    • Security
      • Server security
        • Software
        • Securing the site with a firewall
      • Passwords
      • SSL/TLS
      • CAPTCHA
    • Maintenance
      • Backing up and restoring
        • Using cPanel
        • Using the command line (SSH)
    • Summary
  • Chapter 15: Marketing, SEO, and Customer Retention
    • Marketing sites and stores powered by our framework (and other sites for that matter)
      • Online advertising
        • Buying advertising space
        • Pay-per-click advertisements
        • Advertisement networks provided by search engines
        • Newsletter advertising
        • A word of warning: Search engine penalization
      • Newsletters
      • Marketing materials
      • Affiliate marketing
      • Social marketing
        • Viral marketing
        • Twitter
        • RSS with FeedBurner
    • Search engine optimization
      • On-site SEO
        • Headings
        • Links
        • Up-to-date content
        • Meta tags
        • Sitemap and webmaster tools
      • Off-site SEO
    • Customer retention
      • Newsletters
      • Social features
      • Coupons and voucher codes
    • Summary
  • Appendix A: Interacting with Web Services
    • Google products
      • Adding the feed to the Google merchant center
      • Setting an update schedule
      • Creating the feed
        • Product feed controller
        • Other useful link
      • Alternative—Google Base Data API
      • Others
    • Google Analytics
      • Signing up
      • Tracking e-commerce
        • Add transaction
        • Add item
        • Track transaction
      • Further reading
    • Other services
      • Amazon
      • eBay
    • More to come
    • Summary
  • Appendix B: Downloadable Products
    • Extending products
    • Extending the payment and administration areas
      • Access database
      • Providing access
      • Rescinding access
    • Centralized download area
    • What else is needed?
    • Summary
  • Appendix C: Cookbook
    • Authentication reminders
      • Help! I forgot my password!
        • Generate the reset key, update the user record, and e-mail the customer
        • Reset the password
      • Help! I forgot my username!
    • E-mailing customers
    • Integrating Campaign Monitor
    • Integrating reCAPTCHA
      • On the registration page
      • When processing the registration
    • Tweeting about happy customers
      • Other uses
    • Summary

Michael Peacock

Michael Peacock is a web developer from Newcastle, UK and has a degree in Software Engineering from the University of Durham. After meeting his business partner at Durham, he co-founded Peacock Carter, a Newcastle based creative consultancy specializing in web design, web development and corporate identity.

Michael loves working on web related projects. When he is not working on client projects, he is often tinkering with a web app of his own.

He has been involved with a number of books, having written two books himself (and working on his third): Selling online with Drupal e-Commerce Packt, and Building websites with TYPO3 Packt. He has also done technical reviews of two other books: Mobile Web Development Packt, and Drupal Education & E-Learning Packt.

You can follow Michael on Twitter.

Contact Michael Peacock

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 1 submitted: last submission 26 Jun 2014

Page: 78 | Type: Code

The code is:

WHERE AND c.type=t.ID

It should be:


Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

PHP 5 E-commerce Development +    Puppet 3 Cookbook =
50% Off
the second eBook
Price for both: £21.95

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Plan and develop a flexible, scalable PHP framework with emphasis on e-commerce
  • Implement the Model-View-Controller architecture within the framework and learn how to use the registry design pattern to centralize core features
  • Allow customers to customize their purchase by selecting product attributes, uploading files, and supplying custom text
  • Offer attractive incentives to your customers in the form of discount codes
  • Protect your e-commerce framework by keeping and maintaining regular backups
  • Structure an extendable framework to build a custom e-commerce web site
  • Add features such as product ratings and reviews from customers to enhance user experience
  • Maintain your site using campaign monitor and CAPTCHA tools
  • Create a shopping basket, manage its contents, structure the checkout and order process
  • Filled with useful marketing, Search Engine Optimization, and customer retention tips
  • Create a PHP framework to power your web site with a range of e-commerce features

In Detail

The popularity of online shopping has increased dramatically over the past few years. There are plenty of options available if you not are planning to build your own e-commerce solution but sometimes it's better to use your own solutions. It may be easy to find an e-commerce system but when it comes to extending it or using it you might come across a lot of difficulties.

This book will show you how to create your own PHP framework that can be extended and used with ease, particularly for e-commerce sites. Using this framework you will be able to display and manage products, customize products, create wish-lists, make recommendations to customers based on previous purchases, send email notifications when certain products are in stock, rate the products online, and much more.

This book helps you build a Model-View-Controller style framework, which is then used to put together an e-commerce application. The framework contains template management, database management, and user authentication management. With core functionality in place, e-commerce-focused features are gradually added to the framework including products, categories, customizable products with different variations and customer input, wish-lists, recommendations, the shopping basket, and a complete order process.
At the end of the book, you will have an e-commerce architecture that will take you from viewing or searching for products, and adding them to your basket, through the checkout process and making payment for your order, to your order being dispatched. Focus is placed on flexibility, so that the framework can be extended as the needs of a particular store change, as illustrated by one of the appendices, which goes through the process of modifying the store to sell downloadable products, as well as physical ones.

Supplementary information, such as how to market and promote an online store, as well as take regular backups and perform maintenance is also covered, ensuring you have every chance of success with you own e-commerce framework backed store.

Add dynamism to your e-commerce site for better prospects with your business using PHP


This is a fast-paced tutorial focusing on creating a framework and using it to build an online store through an ongoing case study. Later chapters include examples to illustrate how easily the framework can be adapted for different situations. The framework and code are enhanced and built upon with each chapter, adding more and more functionality.

Who this book is for

If you are a web developer, or anyone looking to increase your understanding of e-commerce site development, this book is for you. Primarily aimed at PHP developers, it is suitable for any web developer interested in enhancing their e-commerce knowledge, or developers looking to move towards PHP.

Intermediate knowledge of PHP development and object-oriented programming is assumed, and basic knowledge of e-commerce principles will be of benefit too.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software