Amirali YaghoutiSenior Software Engineer

woocommerce Case study

A2 Order Fix Box

A2 Order Fix Box is an admin metabox I built for the Javaherian Gallery order screen. When a sale changes after payment, staff can swap items, add shipping or correct a price without touching the gateway or the order status.

The business problem

In a watch store, orders change after payment more often than you would expect: a customer picks a different model, a line total turns out wrong, or an extra courier trip is needed. Editing those orders by hand in WooCommerce produced recalculated totals nobody could trace, and any slip risked corrupting the payment record. I needed a repair tool that leaves the gateway and the order status completely alone.

What I delivered

  • A metabox on the order edit screen with three operations: replace an item with one or more new products, add an extra shipping line, or adjust the line total of an existing item.
  • A split-payment record that separates what came through the gateway from card-to-card transfers, stored as breakdown rows in _a2_fix_offline_rows_json.
  • A full order snapshot in _a2_fix_snapshot_v1 taken before any change, with one-click Undo handled by wp_ajax_a2_fix_undo.
  • A fixed-order badge, column and filter view on both the legacy shop_order list and the HPOS wc-orders table, so repaired orders stay visible.
  • Internal refund registration meta, so money returned outside the gateway is recorded on the order instead of in someone's memory.

Technical approach

  • Every action runs through admin-ajax behind a nonce and a capability gate (manage_woocommerce or edit_shop_orders).
  • A calculation step (wp_ajax_a2_fix_calc) previews old total, new total and the signed difference before anything is applied.
  • The tool never calls the payment gateway and never transitions status; it only edits items, fees and its own meta keys under the _a2_fix_ prefix.
  • Numeric inputs normalize Persian and Arabic digits and strip thousand separators before parsing, because staff paste amounts from invoices.
  • Each applied fix appends to a history log in _a2_fix_history with a human-readable Persian summary.

Result and evidence

The module is at version 1.7.0 and running on the live store admin. I have not formally measured time saved; the practical evidence is that exceptional orders are repaired inside one box with an undo path, instead of through raw order edits.

Commercial value

Order repairs used to be a task only I could do safely. Now sales staff handle them, and the accounting picture of each corrected order stays coherent for whoever reads it later.

implementation-brief.readme

Readable implementation brief

implementation_brief {
  project: "A2 Order Fix Box"
  stack: "WordPress MU plugin, WooCommerce, admin-ajax"
  module: "a2-order-replacement-box.php (v1.7.0)"
  operations: "replace item, extra shipping line, price correction"
  ajax: "a2_fix_calc, a2_fix_apply, a2_fix_rebuild_totals, a2_fix_undo"
  meta: "_a2_fix_snapshot_v1, _a2_fix_history, _a2_fix_offline_rows_json"
  guarantees: "no gateway calls, no status changes, snapshot + undo"
  status: "in production on the Javaherian Gallery admin"
}

What this project shows

This is back-office engineering next to real money, and the interesting part is not the UI. It is deciding what the tool must never do: no gateway calls, no status transitions, no silent edits.

I scoped the write surface to a set of prefixed meta keys and made every mutation reversible. That is how I build anything that sits beside payment data.