1 of 11

Chap 9-10

E-commerce

2 of 11

Discount codes

Discount codes are a great way to both entice new customers into a store, and also to help retain customers with special discounts. The discount code should work by allowing the customer to enter a code, which will then be verified by the store, and then a discount will be applied to the order.

The following are discount options we may wish to have available in our store:

  • A fixed amount deducted from the cost of the order
  • A fixed percentage deducted from the cost of the order
  • The shipping cost altered, either to free or to a lower amount
  • Product-based discounts

3 of 11

Discount codes data

we need to store and account for:

  • The voucher code itself, so that we can check that the customer is entering a valid code
  • Whether the voucher code is active, as we may wish to prepare some voucher codes, but not have them usable until a certain time, or we may wish to discontinue a code
  • A minimum value for the customer's basket, either as an incentive for the customer to purchase more or to prevent loss-making situations (for example a $10 discount on a $5 purchase!)

4 of 11

Discount codes data

  • The type of discount
      • Percentage: To indicate that the discount amount is a percentage to be removed from the cost
      • Fixed amount deducted: To indicate that the discount amount is a fixed amount to be removed from the order total
      • Fixed amount set to shipping: To indicate that the discount amount is to be the new value for the shipping cost
  • Discount amount; that is, the amount of discount to be applied
  • The number of vouchers issued, if we wish to limit the number of uses of a particular voucher code
  • An expiry date, so that if we wish to have the voucher code expire, codes with a date after the stored expiry date would no longer work

​

5 of 11

Discount codes Functionality

  1. Check to see if the customer has entered a voucher code with their order.
  2. If they have, it must look up the voucher code to see if it exists, or doesn't exist.
  3. If the voucher code exists, it must check to see if the code has expired and is still able to be used.
  4. Assuming this is the case, it must then check to see that the customer's basket cost is at least that of the minimum order amount in the discount codes record in the database.
  5. If the voucher is able to be used, it must then determine the type of voucher, and make the relevant discount to either the basket cost, or the shipping costs.

6 of 11

Authentication

When the customer has reviewed their basket and made any necessary changes, we need to allow them to supply their delivery address. Before they can do that; however, we must consider authentication.

If the customer is logged in, then we can simply send them to the "delivery address" page, where they will be presented with their default delivery address based on their user account details. If the customer is not logged in, we need to allow them to either log in, or enter their details to sign up to the store.

To make this process as seamless as possible, there are a few things we should consider:

  • Should the user have to click on a link or a button to view the registration page?
  • Should the user have to click on a link or a button to view the login page?
  • Should we validate the user's e-mail address by sending them an e-mail and asking them to confirm if it is valid

7 of 11

Authentication

The answer to all three of these points is no. If we do any of these things, then we are creating an unnecessary barrier between the customer and them completing their order. Some believe that even requiring the customer to create a user account is a step too far. As we are going to require the customer to make their own account, we should make this less intrusive by allowing them to enter all of their details on one page, with only a few additions as opposed to if they were just supplying their delivery address

8 of 11

9 of 11

Confirmation

The final stage, before payment, is to allow the customer to confirm their order. This involves displaying the order to the customer along with the selected shipping method, payment method, and delivery address. When the customer is happy with the order, we then must:

  • Create a new order
  • Create a new order item entry for each product in the basket
  • Create a new order item attribute association entry for each attribute selected for each product in the basket
  • Delete the contents of the user's basket
  • Send the customer to the payment page

10 of 11

11 of 11

Storing orders in the database

  • Orders: To store the orders.
  • Order statuses: To maintain a list of possible order statuses.
  • Order items: To store items associated with each order.
  • Order item attributes: To store item attributes associated with each item within an order.
  • Payment methods: To store a list of payment methods.

​