Livefoods Direct Checking data…

Backend schema

For the developer: the tables beside WooCommerce, the automated jobs, the payment rules and the admin side.

Feeding plans: backend schema
New tables sit beside WooCommerce (prefix lfd_fp_). Blue = existing WooCommerce data. Arrows point from one record to the many it owns. Pilot: bearded dragons only.
customers WooCommerce, extended
id (WooCommerce customer)
delivery_day (Tue–Fri, per household)
saved_card_token (card only)
terms_accepted_at
marketing_opt_in, opt_in_at
pets
id, customer_id
name, photo
species_id
birth_month (YYYY-MM)
birth_source: known | estimated
length_cm, weight_g (records only)
approval_mode: auto (default) | manual
status: active | archived
species
id
name (Bearded dragon)
pet_type (Lizard)
enabled (pilot on/off)
life_stages set by expert
id, species_id
name: Hatchling | Juvenile |
  Sub-adult | Adult
min_months, max_months
sort_order
notifications sent as Klaviyo events
id, customer_id, pet_id, plan_id
type: approval_1 | approval_2 |
  renewal | stock_swap |
  life_stage | dispatch |
  repeat_flag
sent_at, opened_at
feeding_plans one per 5-week block
id, pet_id, life_stage_id
block_no (1, 2, 3…)
status: pending | active |
  paused | done | cancelled
approvals_sent (0–2)
approved_by: customer | auto
has_repeats (too few meals)
end_reason, ended_at
pet_dislikes
pet_id, food_type_id

Stored by food type, not SKU,
so a dislike carries over when
the pet moves to a new stage
and the pack size changes.
expert_meals set by expert
id, life_stage_id
product_id (WooCommerce SKU)
food_type_id
bigger_pack_product_id
active, sort_order

10–20 per life stage
weekly_boxes one WooCommerce order
id, customer_id
dispatch_date
wc_order_id (one-off order)
payment_status (weekly charge)
status: scheduled | packing |
  dispatched | delivered
  (drives the tracker bulb)
plan_weeks
id, plan_id, week_no (1–5)
expert_meal_id, product_id
box_id
changed_by: system |
  customer | stock_swap
swap_note (shown to customer)
food_types
id
name: Crickets | Locusts |
  Dubia roaches | Waxworms…

Used for dislikes and to
stop back-to-back repeats.
Ask Wiggly
Freshdesk AI (same system as the website chatbot) gets read-only access to the customer’s pets, life stage, dislikes, current plan and next box, so answers are about their pet.
payment_attempts new
id, box_id
attempt_no (1, 2…)
result: paid | declined |
  needs_authentication
gateway_message
pay_link_sent_at, paid_at
admin_audit_log new
id, user_id, role
action: create | update |
  delete | export
table_name, record_id
before, after (JSON)
created_at

Logs meal-list edits and exports
admin roles WordPress roles
shop_manager:
  dashboard, keepers, exports
feeding_plan_expert (new):
  species, life_stages,
  expert_meals only
  no customer data
Automated jobs: when they run
Every dispatch week (example: Wednesday dispatch)
Tue 12pm
Delivery-day changes close, 25 hours before the cutoff
Wed, early morning
Stock check: out-of-stock meals swapped from the expert list, customer told why
Wed, before 1pm
Box builder: one WooCommerce order per household, same meals merged into bigger packs, card charged
Wed 1pm cutoff
Paid boxes go to dispatch. Failed payments held and a pay link sent
After dispatch
Status sync: tracker bulb moves on, dispatch email sent
Across each 5-week plan
Weeks 1 to 3
Plan runs. Customer can swap meals or change the delivery day
Week 4
Plan builder makes the next 5 weeks (no repeat at the join); approval request 1
Week 5
Approval request 2
End of week 5
Auto approve: the next plan starts. Manual approve with no reply: plan pauses
Daily, any week
Life-stage checker: birth month against stage ranges. Stage crossed: new plan and “is growing” notice
Payments (First Data / Clover)
1. Gateway check: confirm which First Data plugin is installed, and that our code can charge the saved card for a normal weekly order, not only a WooCommerce Subscriptions renewal.
2. Card required: a saved card (one per customer in Clover) is needed before a plan starts; PayPal is blocked for feeding plans.
3. Failed payments: if a charge fails or the bank asks for authentication, email a pay-now link, retry once, and hold the box until paid.
4. Expiring cards: warn the customer before the saved card expires, with a link to update it.
5. Charge matches the box: swaps, stock swaps and bigger packs change that week’s price; the weekly charge is always what’s actually in the box.
Admin side (dashboard and expert meal lists)
1. Roles: shop managers see the admin dashboard and exports. A new “Feeding plan expert” role can edit species, life stages and expert meals only, with no access to customer data.
2. Meal list editor: writes life_stages (name, min and max months) and expert_meals (SKU, food type, bigger-pack SKU, active, sort order). Plans already approved keep their meals; edits apply from the next plan built.
3. New table admin_audit_log: user, action, table and record, before and after values, timestamp. Logs every meal-list edit and every export.
4. New table payment_attempts: box_id, attempt_no, result, gateway_message, pay_link_sent_at, paid_at. Feeds the failed payments view. feeding_plans gains end_reason and ended_at for cancellations and pauses.
5. Dashboard reports (read only): accounts vs pet cards from customers and pets; revenue from weekly_boxes; 5-week demand = upcoming plan_weeks grouped by SKU and week, against WooCommerce stock (covered, tight, short); renewals from feeding_plans status and approvals_sent; life-stage changes from birth_month against life_stages; top dislikes from pet_dislikes; most swapped from plan_weeks.changed_by.
6. Exports: keepers CSV and pet cards CSV, both keyed by WooCommerce customer ID, shop managers only, each export logged.