E-Commerce
getting started
depending on the requirements of the project, we need the following plugins to implement an e-commerce website
plugin | purpose | required |
|---|---|---|
ffItem | items to buy | x |
ffCart | collects items and their quantities | x |
ffCheckout | makes sure system has all necessary data for placing order | x |
ffUserArea | stores user's data for recurring visits | x |
ffOrders | stores orders and enables back-office | x |
ffPayment | implements a payment provider | - |
ffPhpMailer | handles confirmation mails more reliably | - |
ffGlobalize | formatting of currency for different locales | - |
ffGoogleAnalytics | analytics | - |
ffPiwik | analytics | - |
ffGeoIP | better detection of a user's region for analytics | - |
ffCookieConsent | gdpr-compliant cookie consent banner | - |
Example: The fashion shop
In this tutorial we will create a simple online store.
We will cover the main aspects of a ff based e-commerce website.
In the first step we will do the basic setup.
prerequisites
When implementing an e-commerce project, it is good practice to first extend the used objects with prefixed ones.
We call this approach "poor man's namespace"-pattern:
To instantiate an object, we can still call ffItem::getInstance().
If called from within an already namespaced object (like nsPresenter), this will still return an instance of our custom nsItem object.
Project-specific custom logic can then be implemented in those classes.
File plugins/myProject/classes/nsItem.php
File plugins/myProject/classes/nsCart.php
File plugins/myProject/classes/nsOrder.php
File plugins/myProject/classes/nsCheckout.php
for API calls we extend the default listeners and code against those.
File plugins/myProject/classes/nsCartListener.php
We create the structure for the shop
We're now ready to define the Items, that we want to sell