Blueprint · Commerce

Discount codes

Discount codes for one small shop. The shop writes codes with rules, a buyer sees exactly what a code takes off, and the rules stop codes being combined into an order that costs the shop money.

L2–L4

Level range

8

Sprints

36

Tasks

Backend and frontend

Built as

By the last sprint

What you’ll build

A shop that takes discount codes. Buyers see exactly what a code takes off before they order, and no mix of codes can make an order free. A code stops working as soon as its last use is taken, and a refund gives back what was actually paid.

What you’ll learn

A skill in every sprint

You show you have it in a pull request your team reviews, then explain it in a walkthrough.

01

Authentication

You can register and sign in a user, keep a request authenticated without asking for the password again, and explain where the credential lives in the browser and why there rather than somewhere else.

02

A cart that survives

You can add, change and remove items, keep the cart across a logout and login, and show a total that reflects prices as they are now.

03

Discount codes

You can apply a valid code, refuse an invalid one with a reason, and show that a single-use code cannot be used twice.

04

An order that moves through states

You can move an order through its states, refuse a transition that should not happen, and show the history of how it got where it is.

05

Going live

Somebody who has never met you can open a URL and use the product — and you can say what is different about the copy running there, where its secrets come from, and what you do when a release turns out to be wrong.

The roadmap

8 sprints, 36 tasks

Every sprint has a goal and a set of tasks. Open a sprint to see the tasks you will pick up.

  1. Sprint 01

    Knowing who is shopping

    A buyer can create an account and come back to it, and nobody can give themselves a shop account.

    4 tasks
    1. Let a buyer create an account and be signed in straight away
    2. Let a buyer sign back in and stay signed in overnight
    3. Let a buyer sign out on a shared laptop and leave nothing behind
    4. Stop anyone creating a shop account from the sign-up form
  2. Sprint 02

    A basket worth discounting

    A buyer can fill a basket that is still there tomorrow, and see a total made of lines they can check.

    4 tasks
    1. Let the shop list items with prices that buyers can see
    2. Keep a buyer's basket when they close the laptop
    3. Show the basket's working, not just a total
    4. Tell the buyer when a price in their basket has changed
  3. Sprint 03

    Codes that come off

    The shop writes a code with rules, a buyer applies it, and a code that does not apply is refused with a reason the buyer can act on.

    5 tasks
    1. Let the shop write a code and see its rules in plain words
    2. Let a buyer apply a code and see exactly what it took off
    3. Refuse a code that does not apply, with a reason the buyer can act on
    4. Make a code's dates mean London time on the shop's own clock
    5. Make the server refuse code changes from anyone but the shop
  4. Sprint 04

    Two codes, one basket

    A second code either combines by a rule the shop set or is refused with the reason, and no mix of codes takes the order to nothing.

    5 tasks
    1. Let the shop decide whether a code can be combined with others
    2. Tell a buyer which code is already on the basket when a second is refused
    3. Apply combined codes in one fixed order: percentages first
    4. Stop any mix of codes taking the goods below zero or touching postage
    5. Check every code again whenever the basket changes
  5. Sprint 05

    The price on the order

    A basket becomes an order at the price the buyer was shown, and the order shows how that price was reached.

    4 tasks
    1. Turn a basket into an order at the price on the screen
    2. Record on each order exactly how its price was reached
    3. Check every code again before an order is placed
    4. Allow only forward moves between order stages, and record each one
  6. Sprint 06

    When a code runs out

    A code with a limit stops at the limit, including when the last two uses arrive at the same moment.

    4 tasks
    1. Let the shop set usage limits on a code and watch the count
    2. Count a code's use when the order is placed, not when the code is typed
    3. Prove that two buyers cannot both take a code's last use
    4. Hold a one-per-customer code to one use per account
  7. Sprint 07

    Taking the discount out

    A refund returns what was paid, for a whole order or part of one, and the code's use count follows a rule the shop can see.

    5 tasks
    1. Refund a whole order for exactly what was charged
    2. Refund one line for its share of what was paid
    3. Refund a partial return without taking back the discount
    4. Keep a refunded order's code use spent, and say so
    5. Show the buyer what came back on their order and why
  8. Sprint 08

    Open for business

    A stranger can reach the shop at its own address and run the whole promotion there, on a clock that agrees with the codes.

    5 tasks
    1. Put the shop on a host that strangers can reach
    2. Read every setting and secret from the environment
    3. Make the live shop agree with the codes about time and money
    4. Have someone else run the whole promotion on the live shop
    5. Make a bad release quick to undo, and failures visible
The reading

Read before you build

Senior engineers read the docs before they touch the code. Every Blueprint comes with short documents on the product and its world, the kind a team hands a new hire. Read them well and you ask sharper questions and walk into every review prepared.

What you are building

The product, the two kinds of people who use it, and why a discount code is a set of rules, not just a form.

How a shop's promotion actually works

Shop knowledge you may not have: margin, what a code is made of, and why shops worry about their own promotions.

More commerce Blueprints

More to build

Not the one for you?

Every Blueprint is planned the same way, across health, shopping, money, education and more.

Browse all Blueprints
Ready?

Build discount codes.

Start your free week. Adaeze runs your kickoff, and Lars reviews every pull request.

Start today, for free