Skip to main content

Pricing Rules

Pricing rules stack with the product base price and staff base costs.

Custom pricing rules

How Costs Are Applied

Understanding how different costs are calculated and combined is essential for setting up pricing correctly.

Cost Components

The total appointment cost consists of:

  1. Product Base Price - Applied once per appointment
  2. Staff Base Cost - Applied once per selected staff member
  3. Pricing Rule Base Cost - Applied once per appointment (when rule matches)
  4. Pricing Rule Slot Cost - Applied per slot segment (when rule matches)
  5. Add-on Costs - Applied once per appointment

Final Cost Formula

Total Cost = Product Price + Staff Cost + Rule Base Costs + (Slot Cost × Number of Slots) + Add-on Costs

Product Base Price

Applied: Once per appointment, regardless of duration or number of slots.

The product's regular price (set in the product Pricing tab) is always added once to the total cost. This is a fixed base cost that doesn't change based on appointment length.

Example:

  • Product price: $100
  • 2-hour appointment: $100
  • 4-hour appointment: $100 (same price)

Staff Base Cost

Applied: Once per selected staff member.

If staff members have base costs configured, each selected staff member's base cost is added once to the total.

Example:

  • Product price: $100
  • Staff member base cost: $20
  • Total: $120 (regardless of appointment duration)

Pricing Rule Base Cost

Applied: Once per appointment when any part of the appointment overlaps with the rule's time/date range.

Base cost from pricing rules is a fixed cost that applies once to the entire appointment if there's any overlap with the rule's conditions.

Example:

  • Product price: $100
  • Rule: Monday 14:00-16:00, Base cost: $10
  • Appointment: Monday 13:00-15:00 (overlaps with rule)
  • Total: $110 (base cost applied once)

Pricing Rule Slot Cost

Applied: Per slot segment, based on how the appointment is divided.

Slot cost is more complex because it depends on how the appointment is divided into segments. This varies based on:

  • Product settings: Duration and interval configuration
  • Product age: Products created before version 5.0.0 use duration-based, newer products use interval-based

Slot Calculation Methods

Interval-Based (New Products - After 5.0.0)

For products created after version 5.0.0, slots are calculated based on the interval setting (how often appointment slots can start).

Example:

  • Product duration: 3 hours
  • Product interval: 1 hour
  • Appointment: 3 hours
  • Slots: 3 segments (each 1 hour)
  • Rule: Slot cost $10
  • Slot cost applied: $10 × 3 = $30

Duration-Based (Legacy Products - Before 5.0.0)

For products created before version 5.0.0, slots are calculated based on the duration setting.

Example:

  • Product duration: 3 hours
  • Product interval: 1 hour
  • Appointment: 3 hours
  • Slots: 1 segment (3 hours)
  • Rule: Slot cost $10
  • Slot cost applied: $10 × 1 = $10

Slot Cost Matching

Slot cost only applies when a slot segment is fully contained within the rule's time range. Partial overlaps don't trigger slot costs.

Example:

  • Rule: Monday 14:00-16:00, Slot cost: $10
  • Appointment: Monday 13:00-15:00
  • Slots: 13:00-14:00, 14:00-15:00
  • Result: Only the 14:00-15:00 slot matches (fully within rule), so $10 is applied once

Complete Example

Let's calculate the total cost for a complex scenario:

Product Settings:

  • Base price: $100
  • Duration: 3 hours
  • Interval: 1 hour (new product, so interval-based)

Staff:

  • Selected staff base cost: $20

Pricing Rules:

  • Rule 1: Monday 14:00-16:00, Base cost: $10, Slot cost: $5
  • Rule 2: Peak hours 09:00-12:00, Slot cost: $15

Appointment:

  • Day: Monday
  • Time: 13:00-16:00 (3 hours)
  • Add-ons: $5

Calculation:

  1. Product base price: $100 (once)
  2. Staff cost: $20 (once)
  3. Rule 1 base cost: $10 (appointment overlaps 14:00-16:00, applied once)
  4. Rule 1 slot cost:
    • Slots: 13:00-14:00, 14:00-15:00, 15:00-16:00
    • Matching slots: 14:00-15:00, 15:00-16:00 (both fully within rule)
    • Cost: $5 × 2 = $10
  5. Rule 2 slot cost: $0 (no overlap with 09:00-12:00)
  6. Add-ons: $5

Total: $100 + $20 + $10 + $10 + $5 = $145

Rule Types

  • Time: Day of Week — apply cost between times on a weekday.
  • Time: Range — apply cost between specific times on a date.
  • Date-based — specific date, date range, or month.
  • Staff-based — apply cost when selected staff matches.

Key Takeaways

  1. Product price is always applied once, regardless of duration
  2. Base costs (product, staff, rule base) are applied once per appointment
  3. Slot costs are applied per slot segment, which depends on product settings
  4. New products (after 5.0.0) use interval-based slot calculation
  5. Old products (before 5.0.0) use duration-based slot calculation
  6. Slot cost matching requires full containment within the rule's time range
note

Cost calculation logic lives in includes/class-wc-appointments-cost-calculation.php.