Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/apursley2012/alex-pizza-assistant/llms.txt

Use this file to discover all available pages before exploring further.

All pricing constants — pizza prices, the tax rate, the delivery fee, and the coupon threshold — are declared directly inside app.js as JavaScript constants. Because Alex Pizza Assistant is a zero-dependency static app, app.js never reads data/menu.json at runtime; that file is reference documentation only. Every time the user submits an answer, handleSubmit() calls calculateTotals() followed by updateReceipt(), which means the receipt panel on the right side of the page stays live throughout the entire conversation, not just at the end.

Pricing Constants in app.js

The three constants that drive every calculation in the app are declared at the top of app.js:
const prices = { small: 8.99, medium: 14.99, large: 17.99 };
const TAX_RATE = 0.1;
const DELIVERY_FEE = 5;
data/menu.json exists in the repository as a companion reference file and its values match these constants, but app.js does not import or fetch it. All arithmetic uses the constants above.

Price Table

The three available pizza sizes and their unit prices are:
SizeUnit Price
Small$8.99
Medium$14.99
Large$17.99
The delivery fee is always a flat $5.00 and is only added when order.method === "delivery". Carry out orders pay no delivery fee regardless of order size.

Total Formula

The grand total is computed in four additive layers.
subtotal = sum(price[size] × quantity)  for each pizza in order.pizzas[]
tax      = subtotal × 0.10
delivery = $5.00  (delivery orders only, otherwise $0)
tip      = customer-entered dollar amount (delivery + card only, otherwise $0)
total    = subtotal + tax + delivery + tip

calculateTotals()

The function that implements the formula above is calculateTotals() in app.js. It uses Array.reduce to iterate over every pizza in order.pizzas[] and sum up the line totals.
function calculateTotals() {
  order.subtotal = order.pizzas.reduce((sum, pizza) => {
    return sum + prices[pizza.size] * pizza.quantity;
  }, 0);
  order.tax = order.subtotal * TAX_RATE;           // TAX_RATE = 0.1
  order.deliveryFee = order.method === "delivery" ? DELIVERY_FEE : 0;  // DELIVERY_FEE = 5
  order.total = order.subtotal + order.tax + order.deliveryFee + Number(order.tip || 0);
}
Note that order.tip defaults to 0 and is only set during the tip step, so the Number(order.tip || 0) guard ensures carry out and cash delivery orders never accidentally add an undefined tip value to the total.

Receipt Panel

The live receipt panel is kept in sync by updateReceipt(), which is called after every valid answer — not just at checkout. This means the customer can watch their subtotal, tax, and fee values update in real time as they add pizzas.
function updateReceipt() {
  document.querySelector("#rName").textContent        = order.userName || "—";
  document.querySelector("#rMethod").textContent      = order.method   || "—";
  document.querySelector("#rPayment").textContent     = getPaymentLabel();
  document.querySelector("#rSubtotal").textContent    = formatMoney(order.subtotal    || 0);
  document.querySelector("#rTax").textContent         = formatMoney(order.tax         || 0);
  document.querySelector("#rDeliveryFee").textContent = formatMoney(order.deliveryFee || 0);
  document.querySelector("#rTip").textContent         = formatMoney(order.tip         || 0);
  document.querySelector("#rTotal").textContent       = formatMoney(order.total       || 0);
  document.querySelector("#rItems").innerHTML         = getPizzaSummary();
}
The DOM elements targeted by updateReceipt() are:
Element IDField
#rNameCustomer name
#rMethodCarry out or delivery
#rPaymentPayment method (or “card ending in XXXX”)
#rSubtotalPizza subtotal
#rTax10% sales tax
#rDeliveryFeeFlat delivery fee
#rTipDriver tip
#rTotalGrand total
#rItemsItemized pizza list rendered by getPizzaSummary()

Coupon Threshold

At the end of a completed order, finishOrder() checks whether the grand total reaches the hardcoded $50 coupon threshold.
if (order.total >= 50) {
  addBubble("Congratulations! You've been awarded a $10 off coupon for your next order.", "bot");
} else {
  addBubble("Orders over $50 receive a free $10 off coupon.", "bot");
}
Orders whose order.total is at or above $50 receive a congratulatory bubble awarding a $10 off coupon for their next order. Orders below $50 receive a reminder bubble noting the threshold, encouraging a larger order in the future. In both cases the message appears after the order total result bubble and before the ETA countdown begins.

Build docs developers (and LLMs) love