1 of 19

� � CMP-3110 ~ E-Commerce Applications Development

Chapter 06

The Shopping Basket

2 of 19

Shopping baskets

  • Shopping baskets the first stage in enabling an online purchase
  • Number of other methods that can facilitate e-commerce, including:
    • One-click payments
    • Service subscription payments
    • Auctions

3 of 19

Shopping baskets

  • One-click payments:
    • customer clicks on the button
    • payment is processed
    • payment processor notifies the administrator:
      • Customer
      • delivery details
      • the amount paid
    • the product and cost data is defined within the payment button
    • Disadvantage:
      • customers can easily order things by mistake
      • customers need to be sure their default delivery details are correct in advance
      • it isn't easy to add voucher codes without adding more clicks

4 of 19

Shopping baskets

  • One-click payments:

5 of 19

Shopping baskets

  • Service subscription payments:
    • generally similar to one-click payments; you click on the subscription level, and then you pay.
    • Subscription sites give access to products or services for the duration of a subscription, from a business perspective
    • This often allows measurable recurring income, and can reduce transaction fees

​

6 of 19

Shopping baskets

  • Auctions
    • Auctions lead to bidding for products
    • The customer commits to purchase the product at a certain price
    • No other customer commits to a higher price within the auction time window

7 of 19

Per-page basket

In case of no items in basket

In case of basket have items

8 of 19

Per-page basket

And, our main basket page should look like this:

9 of 19

Considerations for our shopping basket

  • Stock levels:
    • Is there sufficient stock when a customer adds a product to their basket?
  • Product variations
  • Product customizations
  • Templates:
    • An empty basket
    • summary of the basket
  • Subtotals:
    • We need to calculate subtotals for each product in the basket

​

10 of 19

Basket database

11 of 19

Basket database

12 of 19

Basket contents

  • We have a basket structure in our database, but we now need to allow our customers to control the contents of the basket
  • Allowing them to:
    • View the basket
    • Add products to their basket
    • Add customizable products to their basket
    • Add variations of a product to their basket
    • Edit quantities of products in their basket

13 of 19

Viewing the basket

  • checkBasket method
    1. Why are we using before adding the product?
    2. customer adds a product to their basket twice
    3. The second instance should increment the quantity of the first instance of the product

14 of 19

Adding products

  • we only need to record
    • The product's ID number
    • Information of the user
  • addProduct method
    • First, we check that the product is valid and active
    • Secondly, we check that it is not a customizable product or variations
    • Finally, we check to see if the product is already in the basket
      • If it is, then we increment the product's quantity in the basket
      • if it isn't, then we add it to the basket.

15 of 19

Adding customizable products

  • To facilitate the purchase of such products, there are a number of things we need to do:
    • Restructure the basket database
      • adding a field to store the uploaded file field to store custom text
    • Change how we view the shopping basket
    • Change how we add a product to the basket
    • Process the customized information, if the product was customizable

16 of 19

Adding product variants

17 of 19

Editing quantities

  • customer wants to change the quantity
    • The hope here is obviously that they will increase the quantities and purchase more
    • But equally, we need to allow them to reduce quantities or remove products
  • updateBasket()

18 of 19

Cleaning the basket

  • The customer wants to empty their basket
  • The customer confirms an order
  • The basket contents are old and are not tied to a customer account

​

​

19 of 19

Displaying the basket on every page

  • Most e-commerce websites display a small shopping basket at the top of the page or the side of the page, reminding the customer how many products are in their basket
  • To display the basket on each page we will need:
    • An empty basket template file
    • A basket template file, which displays the number of products in the customer's basket
    • A template tag in our main templates
    • Something in our framework to link into the basket on each page