Tahsin Hasan is a software engineer. He passed the Zend Certication Exam on August 09, 2009 and has become the seventeenth Zend Certied Engineer (ZCE) from Bangladesh. This is the topmost certication on PHP from Zend, the developer of this outstanding scripting language. He is a tech enthusiastic and always keeps himself well-equipped with latest technologies. He has completed his M.Sc. and B.Sc. in Computer Science and Engineering from Jahangirnagar University. Tahsin Hasan has profound knowledge of LAMP environment. His advanced understanding of database environments and Apache web server is an asset. He has prociency in scalability and optimizing of server performance. He has worked with Zend framework, CakePHP, Codeigniter, and Symfony. I'd like to give thanks to my parents and my siblings for their encouragement and also a special thanks to Poorvi Nair and Swapna Verlekar from Packt Publishing. This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Table of Contents Preface 1 Chapter 1: PHP e-commerce 7 e-commerce: Who, what, where, why? 7 An overview of e-commerce 7 eBay 8 Amazon 8 Brick 'N Mortar stores 8 Service-based companies 8 Why use e-commerce? 9 Rolling out your own framework 9 Why PHP? 9 Why a framework? 9 When to use an existing package? 10 Existing products 10 A look at e-commerce sites 10 iStockphoto 11 WooThemes 11 eBay 12 Amazon 12 Play.com 12 e-commerce: What does it need to do/have? 13 Products 13 Checkout process 14 General 14 Our framework: What is it going to do? 14 Our framework: Why is it going to do it? 15 Juniper Theatricals 16 Summary 17 This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Table of Contents [ ii ] Chapter 2: Planning our Framework 19 Designing a killer framework 19 Patterns 20 Model-View-Controller (MVC) 20 Registry 21 Singleton 22 Structure 23 Building a killer framework 24 Pattern implementation 25 MVC 25 Registry 25 Singleton 27 Registry objects 29 Routing requests 54 An alternative: With a router 54 Processing the incoming URL within our registry object 55 index.php 56 .htaccess file 58 Configuration file 58 What about e-commerce? 59 An e-commerce registry? 59 Summary 60 Chapter 3: Products and Categories 61 What we need 61 Product information 62 Category information 62 Structuring content within our framework 63 Pages 63 Content 63 Versioning 64 Building products, categories, and content functionality into our framework 65 Database 65 Content 65 Content types 67 Content versions 68 Products 69 Categories 70 Pages within our framework 70 Model 70 View 73 Controller 74 Products 76 Model 76 View 80 This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Table of Contents [ iii ] Controller 81 Categories 83 Model 84 View 87 Controller 89 Some thoughts 92 Product and category images 92 Routing products and categories 92 Featured products 93 Embedding products 93 Summary 94 Chapter 4: Product Variations and User Uploads 95 Giving users choice 95 Simple variants 96 How could this work? 96 Combinations of variants 96 How will this work? 96 High-level overview 97 Database structure 98 Template switching 100 Templates 103 A look back at simple variants 104 Giving users control 104 How to customize a product? 105 Uploads 105 Custom text 105 Maintaining uploads 106 Security considerations 107 Database changes 107 Extending our products table 107 Template switching 108 Shopping basket preparation 110 Stock control 110 Product variations 111 Product customizations 111 Basket templates 111 Product subtotals 111 Summary 112 Chapter 5: Enhancing the User Experience 113 Juniper Theatricals 113 The importance of user experience 114 Search 114 Finding products 114 This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Table of Contents [ iv ] Search box 115 Controlling searches with the products controller 115 Search results 117 Improving searches 118 Filtering products 119 Product attributes 120 Filter options 122 Processing filter requests 125 Displaying filtered products 129 Improving product filtering 130 Providing wish lists 130 Creating the structure 131 Saving wishes 132 Wish-list controller 132 Add to wish list 135 Viewing a wish list 135 Controller changes 135 Wish-list view 137 Purchases 137 Gift purchases 138 Self purchases 138 Improving the wish list 138 Recommendations 139 Related products 139 Controlling the related products 141 Viewing the related products 142 E-mail recommendations 142 Help! It's out of stock! 143 Detecting stock levels 144 Changing our controller 144 Out of stock: A new template bit 144 Tell me when it is back in stock please! 145 Stock alerts database table 145 More controller changes 146 It is back! 148 Giving power to customers 148 Product ratings 148 Saving a rating 149 Viewing ratings 151 Product reviews 152 Processing reviews/comments 153 Displaying reviews/comments 154 Combining the two? 155 Any other experience improvements to consider? 155 Summary 156 This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 . implementation 25 MVC 25 Registry 25 Singleton 27 Registry objects 29 Routing requests 54 An alternative: With a router 54 Processing the incoming URL within our registry object 55 index .php 56 .htaccess. reviews 152 Processing reviews/comments 153 Displaying reviews/comments 154 Combining the two? 155 Any other experience improvements to consider? 155 Summary 156 This material is copyright and is. within our registry object 55 index .php 56 .htaccess file 58 Configuration file 58 What about e-commerce? 59 An e-commerce registry? 59 Summary 60 Chapter 3: Products and Categories 61 What we