You are previewing PHP 5 e-commerce Development.
O'Reilly logo
PHP 5 e-commerce Development

Book Description

Create a flexible framework in PHP for a powerful ecommerce solution

  • 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

  • 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.

    Table of Contents

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