Product Pricing Calculator — Overview
What it does
The Product Pricing Calculator saves a Base Price to products on save, and applies size upcharges at runtime on the product page and in the cart. It’s designed for speed (clean archive sorting, fast catalog queries) while keeping flexible, per-size pricing at purchase time.
When it runs
- On product save/updates (ACF, WP Admin, Woo, WCFM): computes and stores Base Price.
- At view time (PDP/variations & Cart/Checkout): adds any matching size upcharge to the Base Price.
- Toggleable from the ID Tools → Dashboard card (“Pricing — Hybrid-Lite”).
Inputs it uses
coreprice(number)design_price(number)- Commission (resolved in this order):
- WCFM form override (
product-commission) - Per-product stored override (
product-commissionmeta) basic-commission
- WCFM form override (
- Optional Size Addons map (
tcs_size_addonsoption)
Example formats:- Flat key/value:
{ "xl": 2.00, "2xl": 3.00 } - Table style:
[ {"key":"XL","val":"2"}, {"key":"2XL","val":"3"} ]
Keys are normalized (xl,2xl,3x,10oz,12x18, etc.).
- Flat key/value:
How price is calculated
- Base Price (saved on product save):
base = coreprice + design_price + resolved_commission(never below 0) - Archive price (parent product) saved to
_price:
uses Base Price only (no min-addon baked in). - Variation / Cart runtime price:
final = base + matched_size_upcharge(if any matched).
Note: “Min size addon” is not added to the archived parent price in this setup.
What gets stored (for speed & compatibility)
_tcs_base_price– Base Price used as the source of truth._tcs_min_archive_price– Mirrors Base Price (kept for compatibility)._tcs_price_hash– Hash of inputs to detect changes._price&_regular_price– Set for parent and variations to keep lists/sorting fast._wcfmmp_commission– Persisted as a fixed commission so WCFM reports align.final_price– Mirrors Base Price for themes/integrations that reference it.
Runtime behavior (PDP & Cart)
- PDP variation JSON and price getters return Base + Size Addon so customers always see the correct price for the chosen size.
- Cart/Checkout recalculates line item prices the same way and adds a line item meta note (e.g., “Size upcharge: +$3.00 (2XL)”).
“Shop covers cost”
If a product has shop_covers_cost = "Yes":
- All prices (parent & variations) are forced to $0.00.
- PDP, Cart, and order line items reflect $0.00.
Size addon matching
- Attributes are normalized (e.g.,
XXL,2x,2-xl→2xl). - The largest matching addon among the variation’s attributes is applied (e.g., if both
XLand2XLexist,2XLwins).
Admin toggle & placement
- ID Tools → Dashboard → card “Product pricing Calculator.”
- Uses the same green pill toggle (suite standard).
- When enabled, all save/runtime hooks are active; when disabled, Woo default pricing applies.
Typical workflows
- Vendor updates costs: Edit
coreprice,design_price, or commission → Save → Base Price updates automatically. - Sizes carry premiums: Set
tcs_size_addons(e.g.,xl=2,2xl=3) → Customers see adjusted prices when choosing sizes. - Free products for a group: Set
shop_covers_costto “Yes”. – Feature coming soon
Troubleshooting
- Archive “From $” looks off: Remember, archives show Base Price only; size upcharges are runtime on PDP/Cart.
- Addon not applying: Check
tcs_size_addonskeys normalize to your attribute values (e.g.,XXLshould map to2xl). - Commission ignored: Ensure no WCFM override is set; overrides take priority.
- Caches: After bulk updates, Woo lookup tables/transients are cleared automatically, but some themes cache price HTML; purge theme cache if needed.
Compatibility notes
- Works with Simple and Variable products (parent holds Base; variations inherit Base).
- ACF support: input fields are normalized to single numeric meta.
- WCFM support: honors product-level commission override and persists marketplace commission config.
- Search/sorting: uses saved
_pricevalues for fast queries.
Performance intent
- Save-time compute keeps front-end snappy.
- No extra DB lookups on every page view beyond reading the saved base and a single option for size addons.
Quick glossary
- Base Price: Saved price =
core + design + commission. - Size Addon: Extra charge mapped by size key (applied only at runtime).
- Archive Price: Parent
_priceshown on grids; equals Base Price. - Runtime Price: Price the shopper sees after selecting size; equals Base + Addon.