Precious Metal Pricing
The MetalPricing class (inc/class-metal-pricing.php) manages the retrieval of spot prices and the calculation of final dealer prices on the Dealers Site.
Spot Price Storage
Spot prices are stored as WordPress options, updated periodically by external syncs:
| Option Key | Description |
|---|---|
spot_price_gold | Current gold spot price (USD/oz) |
spot_price_silver | Current silver spot price (USD/oz) |
spot_price_platinum | Current platinum spot price (USD/oz) |
spot_price_modifier_gold | Dollar adjustment added to/subtracted from gold spot |
spot_price_modifier_silver | Dollar adjustment added to/subtracted from silver spot |
spot_price_modifier_platinum | Dollar adjustment added to/subtracted from platinum spot |
markup_modifier_gold | Additional markup modifier for gold |
markup_modifier_silver | Additional markup modifier for silver |
markup_modifier_platinum | Additional markup modifier for platinum |
Markup Modes
| Mode | Formula |
|---|---|
each_fixed | final_price = spot_price + fixed_markup_per_unit |
weight_percent | final_price = spot_price + (spot_price × markup_rate) per ounce × weight |
Public REST API
The GET /suma/v1/spot-prices endpoint (registered by Endpoints\Pricing) exposes current prices publicly:
[
{
"name": "gold",
"price": "1927.40",
"change": "+0.32%",
"changeType": "increase"
},
{
"name": "silver",
"price": "23.18",
"change": "-0.10%",
"changeType": "decrease"
}
]
This endpoint powers the Price Ticker Elementor widget shown site-wide.
Price Import Endpoint
The POST /suma/v1/prices endpoint (registered by Endpoints\Pricing) receives price data from the Middleware Platform's HTTP Sync Target and writes it to WooCommerce product meta. This updates _price, _regular_price, _markup_rate, _markup_mode, _volume_pricing, and _metal_weight on WooCommerce product posts.
The compact payload field map used during import includes:
wa-> base ask / regular pricemr-> markup ratemm-> markup modet-> tier pricing JSONw-> metal weight
Authentication uses a shared token defined as PRICES_API_TOKEN in wp-config.php.