Book Image

PHP 5 E-commerce Development

By :
Book Image

PHP 5 E-commerce Development

By:

Overview of this book

<p>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.<br /><br />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.<br /><br />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.<br />&nbsp;<br />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.<br /><br />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.</p>
Table of Contents (23 chapters)
PHP 5 e-commerce Development
Credits
About the Author
About the Reviewers
Preface

Preface

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 e-mail 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, in addition to taking regular backups and performing maintenance is also covered, ensuring you have every chance of success with your own e-commerce framework-backed store.

What this book covers

Chapter 1, PHP e-commerce, looks into the growing need and use of e-commerce, including various popular online retailers, and discusses what we are going to do throughout the book, and why.

Chapter 2, Planning our Framework, introduces you to several key architectural patterns, including MVC, Registry, and Singleton, as we develop the structure and core functionality for our framework including template management, database management, and user authentication.

Chapter 3, Products and Categories, takes a step further and demonstrates how to display and categorize products within our framework for our customers.

Chapter 4, Product Variations and User Uploads, moves on to enhancing the standard product listings with customizable products, product variations, and allowing customers to upload files with their orders.

Chapter 5, Enhancing the User Experience, discusses tips and tricks to enhance user experience by looking at search, product filtering, providing wish lists, sending e-mail notifications, and other useful enhancements for our customers.

Chapter 6, The Shopping Basket, demonstrates how to structure, build, and manage the shopping basket supporting both standard and customized products.

Chapter 7, The Checkout and Order Process, looks at the checkout and order process implemented by some of the popular e-stores and their pros and cons, to chalk out the process for our own framework.

Chapter 8, Shipping and Taxes, focuses on calculating shipping costs based on different methods, integrating third-party shipping APIs, sending shipping and tracking notifications on orders, and integrating tax costs into our system.

Chapter 9, Discounts, Vouchers, and Referrals, aims at extending our framework to encourage new customers and orders by promoting our store through discount codes, purchasable vouchers, and referral discounts.

Chapter 10, Checkout, ties everything together, as most of our checkout functionality is already in place, and extends our order process to leave our customers with a confirmed order, ready for their payment.

Chapter 11, Taking Payment for Orders, introduces payment processing to the framework, covering different modes of payment and various post-payment steps involved.

Chapter 12, User Account Features, walks through the development of a customers area where they can see as well as edit their orders and profile information.

Chapter 13, Administration, walks through the development of an administrators area where they can see orders, products, and settings, and add, edit, and remove these.

Chapter 14, Deploying, Security, and Maintenance, looks at deploying our site using the framework into a live environment and examines the security and maintenance concerns, introducing different ways to enhance security of our framework and to restore a live site from a backup.

Chapter 15, Marketing, SEO, and Customer Retention, discusses hints and tips for effectively marketing and promoting websites and e-commerce stores with online marketing techniques, search engine optimization, and customer retention strategies.

Appendix A, Interacting with Web Services, explains how we may interact with other e-commerce-related web services, such as Google products, Google Analytics, Amazon web services, and eBay developer center, in order to target new markets, or to make tasks easier for us.

Appendix B, Downloadable products, illustrates how to extend our store to allow downloadable products.

Appendix C, Cookbook, goes through a number of useful code snippets to enhance the framework and our store.

What you need for this book

In the course of this book, you will need the following software utilities to try out various code examples listed:

  • Apache 1.3 or above (2 recommended)

  • Apache mod_rewrite module

  • MySQL 5.0

  • PHP 5.0 (5.2+ recommended)

The above can be installed using a package such as WampServer 2.0 for Windows.

For development, a text editor is all that is required, though one with syntax highlighting would be beneficial.

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.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The suffix of ecomframe is used to allow us to store multiple database connection details within the same array."

A block of code is set as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{title}</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="{metadescription}" />
<meta name="keywords" content="{metakeywords}" />
</head>
<body>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

SELECT v.name AS product_name, c.ID AS product_id,
(SELECT GROUP_CONCAT( a.name,'--AV--', av.ID, '--AV--',
av.name SEPARATOR '---ATTR---' )
FROM product_attribute_values av,
product_attribute_value_association ava,
product_attributes a
WHERE a.ID = av.attribute_id AND av.ID=ava.attribute_id
AND ava.product_id=c.ID ORDER BY ava.order ) AS attributes,
p.image AS product_image, p.stock AS product_stock, p.weight AS product_weight, p.price AS product_price, p.SKU AS product_sku, p.featured AS product_featured, v.heading AS product_heading, v.content AS product_description, v.metakeywords AS metakeywords, v.metarobots AS metarobots, v.metadescription AS metadescription FROM content_versions v, content c, content_types t, content_types_products p WHERE c.active=1 AND c.secure=0 AND c.type=t.ID AND t.reference='product' AND p.content_version=v.ID AND v.ID=c.current_revision AND c.path='{$productPath}'

Any command-line input or output is written as follows:

Mysql -u username -p databasename < /home/junipert/backup.sql

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Once we have entered the username and password, we need to click on the Next Step button."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an email to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/9645_Code.zip to directly download the example code.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in the text or the code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.