Scroll page back to the top

E-commerce application with PHP, MySQL, Ajax and PayPal

E-commerce application with PHP, MySQL, Ajax and PayPal

Learn how to create your very own E-commerce application with Object Oriented PHP, MySQL, Ajax and PHP. This series introduces Object Oriented Programming with PHP - you will learn what Classes and Methods are and how to use them in order to build your own application. It explains how to create Ajax based shopping basket, which will allow you to add and remove products form the basket without reloading the page. You will also learn how to use PayPal in order to process payments and Instant Payment Notification with the update of the payment status made by the client. At the end of this series you will have a fully featured E-commerce system!
Over 14.5 hours : 210 videos : 24 chapters

Time: 877:36 min / Price: £120.00

Sebastian Sulinski on 15th Dec 2010

Add to the basket
 

Introduction

Watch now!

What we are going to be developing (01:47 min)

 

Framework

Watch now!

Page structure (02:25 min)

 
Watch now!

Autoloader (03:51 min)

 
Watch now!

Configuration file (04:35 min)

 
Watch now!

Configuration file (continue) (05:08 min)

 
Watch now!

Include path (04:31 min)

 
Watch now!

Class and method (05:07 min)

 
Watch now!

Properties scope (04:29 min)

 
Watch now!

Run method (02:52 min)

 
Watch now!

Url class (04:11 min)

 
Watch now!

Getting the right page (06:05 min)

 
Watch now!

Url parameters (02:11 min)

 

Database

Watch now!

Database class (06:19 min)

 
Watch now!

MySQL connect (04:06 min)

 
Watch now!

Escape method (03:58 min)

 
Watch now!

MySQL query (04:24 min)

 
Watch now!

Fetch records (03:41 min)

 

Introduction to Object Oriented Programming

Watch now!

Static vs Non-static (07:40 min)

 
Watch now!

Modifying properties (05:32 min)

 

Catalogue

Watch now!

Business class (05:46 min)

 
Watch now!

Business details (03:33 min)

 
Watch now!

List of categories (06:14 min)

 
Watch now!

Active link (04:31 min)

 
Watch now!

Catalogue page (04:28 min)

 
Watch now!

Category pages (04:10 min)

 
Watch now!

Product image (04:12 min)

 
Watch now!

Product image (continue) (06:58 min)

 
Watch now!

Product details (06:37 min)

 
Watch now!

Shortening description (05:25 min)

 
Watch now!

Image unavailable (03:43 min)

 
Watch now!

Active button (06:42 min)

 

Pagination

Watch now!

Paging class (05:33 min)

 
Watch now!

Current page (04:24 min)

 
Watch now!

Total number of pages (02:38 min)

 
Watch now!

Get records (05:25 min)

 
Watch now!

Paging links (06:19 min)

 
Watch now!

Paging links (continue) (04:43 min)

 
Watch now!

Get paging (02:31 min)

 

Small basket

Watch now!

Small basket plugin (06:06 min)

 
Watch now!

Adding jQuery (02:52 min)

 
Watch now!

Add to basket (04:19 min)

 
Watch now!

Ajax call (02:48 min)

 
Watch now!

Get product (05:47 min)

 
Watch now!

Session class (03:42 min)

 
Watch now!

Update small basket (04:22 min)

 
Watch now!

Refresh small basket (03:57 min)

 
Watch now!

Refresh small basket (continue) (02:53 min)

 
Watch now!

Expanding Basket class (03:37 min)

 
Watch now!

VAT/Tax rate, number of items and sub-total (05:07 min)

 
Watch now!

VAT/Tax amount and total (03:48 min)

 
Watch now!

Number format (02:58 min)

 

Main basket

Watch now!

Product page (07:18 min)

 
Watch now!

Product page (continue) (06:10 min)

 
Watch now!

Basket page (03:57 min)

 
Watch now!

Basket layout (04:48 min)

 
Watch now!

Getting content of the basket (04:39 min)

 
Watch now!

Displaying content of the basket (04:54 min)

 
Watch now!

Item total and remove item methods (05:11 min)

 
Watch now!

Sub-total and VAT/Tax amounts (03:59 min)

 
Watch now!

Update quantity (07:45 min)

 
Watch now!

Refresh main basket (04:13 min)

 
Watch now!

Refresh main basket (continue) (03:40 min)

 
Watch now!

Generate new basket content (03:01 min)

 
Watch now!

Remove item from the basket (06:35 min)

 

Checkout

Watch now!

Client details form (07:27 min)

 
Watch now!

Form and Country class (07:15 min)

 
Watch now!

Process $_POST (07:21 min)

 
Watch now!

Sticky text field (04:08 min)

 

Validation

Watch now!

Validation class (06:06 min)

 
Watch now!

Process method (04:55 min)

 
Watch now!

Check method (01:45 min)

 
Watch now!

Check special method (04:09 min)

 
Watch now!

isValid method (03:15 min)

 
Watch now!

Format and validate method (04:28 min)

 
Watch now!

Hash function (02:57 min)

 
Watch now!

Form validation (07:46 min)

 

Login

Watch now!

Login class (06:42 min)

 
Watch now!

Redirect method (04:14 min)

 
Watch now!

Login form (04:26 min)

 
Watch now!

Registration form (05:56 min)

 
Watch now!

Countries menu (01:54 min)

 
Watch now!

User class (05:55 min)

 
Watch now!

Login user (04:44 min)

 
Watch now!

Referrer url (04:31 min)

 

Registration

Watch now!

Starting with registration form (03:21 min)

 
Watch now!

Validation (04:42 min)

 
Watch now!

Sticky form fields (03:29 min)

 
Watch now!

Processing input (07:10 min)

 
Watch now!

Working with date (05:59 min)

 
Watch now!

Add new user record (06:39 min)

 
Watch now!

Insert method (06:06 min)

 
Watch now!

Email class (07:51 min)

 
Watch now!

Process email (06:16 min)

 
Watch now!

Fetch email (03:15 min)

 
Watch now!

Email content (04:20 min)

 
Watch now!

Testing (01:40 min)

 
Watch now!

Activate page (07:23 min)

 
Watch now!

Activate method (01:52 min)

 
Watch now!

Check for a duplicate email address (05:13 min)

 

Order summary

Watch now!

Shipping address (05:29 min)

 
Watch now!

Update user method (03:42 min)

 
Watch now!

Update method (04:19 min)

 
Watch now!

Order summary page (04:55 min)

 
Watch now!

Order items (08:21 min)

 
Watch now!

Token and formatting (05:39 min)

 
Watch now!

Proceed to PayPal button (07:34 min)

 
Watch now!

Send to PayPal Ajax call (03:24 min)

 

Order

Watch now!

PayPal file (05:59 min)

 
Watch now!

Create order (07:22 min)

 
Watch now!

Order tables (02:23 min)

 
Watch now!

Add items (05:16 min)

 
Watch now!

Get order details (04:59 min)

 

PayPal

Watch now!

PayPal class (05:59 min)

 
Watch now!

PayPal class properties (05:11 min)

 
Watch now!

Constructor (03:29 min)

 
Watch now!

Add product to array (04:32 min)

 
Watch now!

Add order items to the class instance (04:00 min)

 
Watch now!

Add client details to the class instance (04:46 min)

 
Watch now!

Add field method (03:19 min)

 
Watch now!

Render method (01:59 min)

 
Watch now!

Process fields (04:01 min)

 
Watch now!

Common variables (05:31 min)

 
Watch now!

Pre-populate method (03:16 min)

 
Watch now!

Output preview (03:16 min)

 

Sandbox

Watch now!

PayPal Sandbox account (04:26 min)

 
Watch now!

Sandbox testing (03:47 min)

 
Watch now!

Account preferences (06:00 min)

 
Watch now!

Return and cancel pages (02:17 min)

 
Watch now!

Clear basket (02:18 min)

 

Instant Payment Notification

Watch now!

Validate IPN (07:45 min)

 
Watch now!

Get IPN data (03:33 min)

 
Watch now!

CURL response (03:50 min)

 
Watch now!

IPN verification (02:58 min)

 
Watch now!

Approve transaction (03:55 min)

 
Watch now!

Log file (05:28 min)

 
Watch now!

Testing IPN (05:26 min)

 
Watch now!

Save IPN response (07:55 min)

 
Watch now!

Final IPN testing (03:37 min)

 

Clients area

Watch now!

Navigation (05:53 min)

 
Watch now!

Get client orders (04:03 min)

 
Watch now!

Display orders (03:28 min)

 
Watch now!

Display orders (continue) (05:01 min)

 
Watch now!

Invoice page (05:34 min)

 
Watch now!

Invoice layout (04:23 min)

 
Watch now!

Order details (04:52 min)

 
Watch now!

Print invoice option (04:03 min)

 
Watch now!

Logout method (02:50 min)

 

Control panel

Watch now!

CMS template (04:04 min)

 
Watch now!

Navigation (05:10 min)

 
Watch now!

Login form (03:19 min)

 
Watch now!

Processing login (03:15 min)

 
Watch now!

Admin class (03:18 min)

 
Watch now!

Login admin method (03:22 min)

 
Watch now!

Testing (01:57 min)

 
Watch now!

Restrict access (02:51 min)

 

Products

Watch now!

Products pages (04:13 min)

 
Watch now!

List of pages (05:34 min)

 
Watch now!

Get all products (04:51 min)

 
Watch now!

Paging (05:28 min)

 
Watch now!

Parameters for the search form (04:55 min)

 
Watch now!

Search testing (02:58 min)

 
Watch now!

Add product page (07:06 min)

 
Watch now!

Categories menu (03:28 min)

 
Watch now!

Sticky form fields and validation (02:07 min)

 
Watch now!

Validation messages (03:29 min)

 
Watch now!

Add product method (02:44 min)

 
Watch now!

Upload class (02:51 min)

 
Watch now!

Upload method (05:09 min)

 
Watch now!

Process form (03:36 min)

 
Watch now!

Update product method (04:18 min)

 
Watch now!

Confirmation pages (02:56 min)

 
Watch now!

Edit product page (05:00 min)

 
Watch now!

Update product and remove image (03:32 min)

 
Watch now!

Confirmation pages (01:42 min)

 
Watch now!

Remove product page (02:59 min)

 
Watch now!

Process request (02:44 min)

 
Watch now!

Remove product method (03:42 min)

 

Categories

Watch now!

Categories page (01:34 min)

 
Watch now!

List of categories (03:47 min)

 
Watch now!

Add category (03:43 min)

 
Watch now!

Duplicate category (05:07 min)

 
Watch now!

Add category method (02:16 min)

 
Watch now!

Edit category (03:51 min)

 
Watch now!

Update category method (03:58 min)

 
Watch now!

Remove category (03:14 min)

 

Orders

Watch now!

Orders page (01:28 min)

 
Watch now!

List of orders (04:40 min)

 
Watch now!

Payment status (03:14 min)

 
Watch now!

Get orders method (02:21 min)

 
Watch now!

View order page (05:54 min)

 
Watch now!

Display order layout (03:18 min)

 
Watch now!

Products, Sub-total, VAT/Tax and Total (04:51 min)

 
Watch now!

Client details (04:24 min)

 
Watch now!

Order status and notes (04:32 min)

 
Watch now!

Buttons (04:20 min)

 
Watch now!

Statuses menu (06:19 min)

 
Watch now!

Invoice (01:57 min)

 
Watch now!

Remove order (04:09 min)

 

Clients

Watch now!

Clients page (02:03 min)

 
Watch now!

Clients records (03:09 min)

 
Watch now!

Get users method (03:00 min)

 
Watch now!

Edit user (06:02 min)

 
Watch now!

Duplicate email address (02:25 min)

 
Watch now!

Remove client (02:35 min)

 
Watch now!

Remove user method (02:48 min)

 

Business

Watch now!

Business page (02:34 min)

 
Watch now!

Process form (03:33 min)

 
Watch now!

Update business method (05:21 min)

 
Watch now!

Confirmation pages (01:32 min)

 
Watch now!

Logout option (01:56 min)

 
 
 
 

Discussion (26 comments)

  • Ubaldo

    Ubaldo on Saturday, 17th September 2011

    Hi Sebastian,
    great work and thank you for the tutorial that you created, has been very helpful to have a better idea on the workflow to be addressed.

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Saturday, 17th September 2011

    Thanks Ubaldo - glad you enjoyed it.

    Reply

  • Gordon Jeffrey

    Gordon Jeffrey : @jeffreycomputin on Thursday, 22nd September 2011

    Awesome example. Clearly explained and very well constructed. The follow up service has been excellent too. Well worth the money. Sebastian, your site is now on my favourites bookmark. :-)

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Thursday, 22nd September 2011

    Thanks Gordon - much appreciated!

    Reply

  • Qaysar Akbar

    Qaysar Akbar on Thursday, 10th November 2011

    Hi Sebastian,
    I was wondering if it is possible to add ajax to the Login and Register process.
    A little scroller and message displaying 'Processing....Please wait' would be a nice feature.
    Is the class easy to upgrade or does it require alot of modification??
    As always a very nice and brilliant done tutorial.
    Thank You
    Kind Regards

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Sunday, 13th November 2011

    Hi Qaysar,
    It's not much of a PHP class, but JavaScript behaviour as you would have to use Ajax in order to do it this way. You could use this tutorial in order to convert the Login and Registration forms to Ajax based : http://www.ssdtutorials.com/tutorials/series/web-form-jquery-ajax-php.html.

    When you submit the form - before posting form values to the PHP script, you would simply replace the form with the animated gif or message like 'Processing...' and you could do it in two ways.

    One way would be to have form and the message / gif on the page already - where message would be hidden. When the form is submitted, you hide the form and show the message using jQuery's show() and hide() methods.

    The other approach would be to replace the form with the message using replaceWith() method - whatever suits you best.
    I would most probably use the first approach - as with the animated gif it would pre-cache it when the page first loads.

    I hope this answers your question.

    Reply

  • Qaysar Akbar

    Qaysar Akbar on Wednesday, 16th November 2011

    The way the validation is done on these forms is totally different as the one in the E-Commerce tutorial, which is split into a few files:

    Validation
    Login
    

    Would the whole structure of how the validation is being called need to change?
    Kind Regards

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Wednesday, 16th November 2011

    Hi Qaysar,
    Not necessarily the whole structure - you just have to use these classes inside of the file that's processing the ajax request - using exactly same approach. The only difference would be the outcome. You would echo the JSON array using json_encode() to pass values back to the JavaScript. It would contain either array of errors or successful message.

    Reply

  • Keshav Naidu

    Keshav Naidu on Thursday, 17th November 2011

    You are really Awesome man !

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Thursday, 17th November 2011

    Thanks Keshav.

    Reply

  • Rakesh Singh

    Rakesh Singh on Saturday, 31st December 2011

    Hi Sebastian,
    I am interested in buying this series but I have a few questions.
    I had a look at the titles of the tutorials and wanted to ask if the following features are covered within this tutorial as I could not see the reference to them.
    1) Order status updates
    2) Email customer when they place an order
    3) Email customer on status updates
    4) How easy is it to change the type of products being sold as I viewed your introduction video and if I wanted to change it to like shoes or clothes how would the size(s) be added to this
    5) Is the index page blank, static or dynamic

    Thanks

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Saturday, 31st December 2011

    Hi Rakesh,
    Let me answer your questions one by one:

    1. Order status updates
    When the order is placed it will automatically display in the control panel under the Orders section where you can click on the View link in order to preview it as well as chance its status (i.e. Pending, Processing, Dispatched etc.) and put some additional notes, which are only for the administrative purposes.

    2. Email customer when they place an order
    At the moment system does not send email to the client confirming the order, but this can be easily done with the Email class built during this series, which has all of the methods necessary to send an email for whatever purpose.

    3. Email customer on status updates
    We do not send status update to clients by email due to the fact that if someone would change the status by mistake and then change it back - it would automatically trigger two emails to the client. You can also add this feature using the Email class.

    4. How easy is it to change the type of products being sold as I viewed your introduction video and if I wanted to change it to like shoes or clothes how would the size(s) be added to this
    Changing category of the product is as easy as selecting different category from the dropdown menu, however, we do not use attribute sets with categories, therefore there won't be any other changes with regards to the product specification. All attributes have to be included in the product description with this specific system.

    5. Is the index page blank, static or dynamic
    It's a static page where you would type the content directly in the file, however, once you've completed the entire project you should easily be able to create another module for page management.

    I hope this answers your questions.

    Reply

  • Rakesh

    Rakesh on Saturday, 31st December 2011

    Hi Sebastian,
    I was hoping you had a solution for the comment I placed on this tutorial the other day.
    Thanks

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Saturday, 31st December 2011

    Hi Rakesh,
    Sorry - which comment exactly?

    Reply

  • Athar Khan

    Athar Khan on Thursday, 26th January 2012

    hi Sebastian,

    I am your fan since I've bought this tutorial, buddy you are awesome.

    I have one question which is unrelated to this tutorial but I wish if you could create another tutorial on my query. I want to know how can I hide URL of the flash files, if at some point I would want to create online tutorials like you and I dont want the URL of the files to be known. Similarly, like I am subscribed to this tutorial but I cannot see the URL of each tutorial file.

    I hope you can help me understand this.

    Thank you
    Athar

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Thursday, 26th January 2012

    Hi Athar,
    To embed flash videos the way it is done on our website you can use the free jQuery plugin from here: jQuery Tools Flashembed. It's pretty straight forward and nice method of embeding flash videos without having a lot of code displayed directly on the page.

    Reply

  • Maxime Trudel

    Maxime Trudel : @pingouincrea on Saturday, 11th February 2012

    Hi Sebastian, I have a quick question for you. I would like to use the e-commerce tutorial for my projects but where I live there are 2 taxes - one over order (subtotal ->tax 1 -> subtotal 2 -> tax 2 = grand total) is there anyway to do that with your tutorial?
    thx
    Great job

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Saturday, 11th February 2012

    Hi Maxime,
    The system as it stands only accepts one tax rate. To have multiple tax rates you would have to have a separate table with tax rates and then assign the relevant tax rate to each product in the control panel. Once each product has its own tax rate, you'll be able to calculate the total tax in the basket based on product's total and tax rate associated with it.

    If your tax rate is based on the sub-total of the order then you'd have to simply change the tax rate if the sub-total is over the specific amount - all this can be easily done in the Basket class created in this tutorial.

    Reply

  • elie

    elie on Friday, 24th February 2012

    Hi sebastian

    I was wondering before purchasing the course , if i will build my project based on your style , but i want to seel digital goods , like a video library , but users has to pay each month , how can i remind the users 5 days before the end of their registration that they have to pay again ?

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Friday, 24th February 2012

    Hi Elie,
    The best way to achieve this would be to set up a Cron job on the server in order to execute specific PHP file, which would check whether the user's renewal is due and trigger an email if so.

    There are many tutorials out there on how to set up Cron jobs and most of the hosting control panels have specific tools to interact with the crontab so you don't have to use shell in order to save your changes.

    The way to do it on the database and form within the PHP would be to add new field to the users table called for instance 'renewal_date'. This field would always store the date the renewal is due. Say someone has just registered and purchased the subscription - once subscription has been approved by PayPal, you would update this field with the value of the today's date plus 1 month - and you could do it using SQL statement like so:

    UPDATE `users`
    SET `renewal_date` = DATE_ADD(CURDATE(), INTERVAL 31 DAY);
    WHERE `id` = ?
    

    Or by using Month keyword:

    UPDATE `users`
    SET `renewal_date` = DATE_ADD(CURDATE(), INTERVAL 1 MONTH);
    WHERE `id` = ?
    

    Then to check (which would be triggered by cron) you could use the following statement:

    SELECT *,
    IF (
    	CURDATE() < `renewal_date`,
    	0,
    	1
    ) AS `renewal`
    FROM `users`
    WHERE `id` = ?
    

    This would give you the record of the specific user, where you'd have an additional field called renewal.
    This field would indicate whether the user needs to renew his account or not - 1 would stand for true and 0 for false.

    Based on this result you could trigger an email to the client informing about the renewal being due and de-activate user's account if necessary.

    I hope this answers your question.

    Reply

  • Nawaf

    Nawaf on Friday, 16th March 2012

    That is one of the most enjoyable and beautiful tutorials I have ever watched , the really basic thing it lacks is an advanced search form for visitors that includes basic search choices like:

    1- Keyword search box
    2- Brand name drop-down
    3- Price range (Min-Max) drop-down
    4- Date added range drop-down

    And some sort of buttons to be clicked to arrange products by date added and price.
    I wish Sebastian complete that unique tutorial with add-on series that include adding those basic useful things in every online e-store, that will be really appreciated, and thanks to you Sebastian you have really filled a big gap with your beautiful works.

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Friday, 16th March 2012

    Hi Nawaf,
    I'm currently working on the add-on for E-commerce system, which explains how to amend the Url class in order to create static looking urls and how to add meta tags. Once I'm finished with this one I'll start on the search form. Thanks for the suggestion!

    Reply

  • Nawaf

    Nawaf on Monday, 16th April 2012

    Hi Sebastian, can I get a little help here please, I am getting this warning about timezone setting:

    "Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for '-7.0/DST' instead in D:\UwAmp\www\classes\Helper.php on line 75"

    How can I use "date_default_timezone_set()" function to set timezone to match a specific country's timezone, like "date_default_timezone_set(Asia/Bahrain)" ?

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Monday, 16th April 2012

    Hi Nawaf,
    Yes - if you place the following right at the beginning of your index.php file that should solve the problem:

    date_default_timezone_set("Asia/Bahrain");
    

    Reply

  • Nawaf

    Nawaf on Monday, 16th April 2012

    Thanks it worked, I added date_default_timezone_set('Asia/Bahrain'); after

    Reply

  • Sebastian Sulinski

    Sebastian Sulinski : @designtutorials on Monday, 16th April 2012

    Great - it should usually be right at the top or somewhere at the top of your script as it sets the default time zone for your whole application.

    Reply

 
 
Add a comment
Add Comment