Skip to main content

NFusion Integration

NFusion Solutions is the precious metals data and catalog platform that Scottsdale Mint uses as its pricing data source, product catalog reference, and order fulfillment reporting destination.


Overviewโ€‹

NFusion serves two primary roles:

  1. Pricing Source โ€” Live spot prices, premium rates, and product pricing data flow from NFusion (via a Laravel middleware) to the WooCommerce product catalog.
  2. Order Destination โ€” Completed WooCommerce orders are exported to NFusion for fulfillment reporting and catalog inventory management.

Environment Variablesโ€‹

VariableDescription
NFUSION_API_KEYNFusion order/data API key
NFUSION_PRODUCT_API_KEYNFusion product catalog API key
NFUSION_PRODUCT_CATALOG_BASE_URLNFusion catalog base URL (e.g., https://scottsdalemint2.nfusioncatalog.com)

Pricing Data Flowโ€‹

The Laravel middleware (external to this repository) is responsible for:

  1. Authenticating with NFusion's pricing API
  2. Fetching current spot prices for gold, silver, platinum, palladium
  3. Fetching per-SKU premium rates and product pricing
  4. Transforming the data into the format expected by the WP REST API
  5. Calling POST /wp-json/suma/v1/product/update-prices every minute

The WordPress side (this codebase) handles:

  1. Receiving the price payload
  2. Updating WooCommerce product prices via \Suma\Product\PriceUpdater
  3. Cache invalidation

See Price Updates for the update endpoint details.


Order Export to NFusionโ€‹

When an order is completed in WooCommerce, selected order data is pushed to NFusion for:

  • Fulfillment reporting
  • Catalog inventory synchronization
  • Sales analytics

The export process is triggered on the woocommerce_order_status_completed action.

Data exported:

  • Order ID, order number
  • Order date and time
  • Customer information (name, address)
  • Line items (SKU, product name, quantity, price, metal type, weight)
  • Payment method
  • Shipping method and tracking

Product Catalog Importโ€‹

When new products are added to the Scottsdale Mint catalog, the NFusion import tools in tools/nfusion-import/ help prepare the data:

retail-import.phpโ€‹

Maps WooCommerce product export data to NFusion's product import format:

WooCommerce FieldNFusion Field
skuItem Code
nameProduct Name
_metal_typeMetal Type (mapped: Gold โ†’ G, Silver โ†’ S, Platinum โ†’ P)
_metal_weight_troy_ozWeight (troy oz)
Product categoryProduct Family

Output: nfusion-retail-import.csv โ€” ready for import into the NFusion catalog portal.

retail-tiers-import.phpโ€‹

Converts WooCommerce volume pricing tiers to NFusion's price tier import format:

Input: WooCommerce product's _volume_pricing JSON meta Output: nfusion-price-tiers-import.csv


Live Price Chart Widgetโ€‹

The nfusion/live-price-chart/ directory contains the NFusion spot price chart widget โ€” a JavaScript widget that displays live precious metals prices.

Setup:

cd nfusion/live-price-chart
npm install
npm run dev # Development
npm run production # Production build

The widget is embedded in Elementor pages via:

  1. A custom Elementor widget that renders the NFusion embed code
  2. OR an Elementor HTML widget with the NFusion JavaScript embed snippet

Configuration: The widget ID and settings are managed in widgetcdn.nfusionsolutions.com/ and configured at the NFusion account level.


NFusion API Rate Limitsโ€‹

The Laravel pricing middleware handles NFusion's API rate limits. The WordPress side should not make direct calls to NFusion APIs. All NFusion data arrives via the price update REST endpoint.


Troubleshootingโ€‹

IssueCheck
Prices not updatingCheck Laravel middleware is running; check /wp-json/suma/v1/product/update-prices returns 200
Wrong prices on stagingStaging has separate test NFusion catalog โ€” verify NFUSION_PRODUCT_CATALOG_BASE_URL env var
Order not appearing in NFusionCheck the order export hook; verify NFUSION_API_KEY is valid; check Wonolog error logs
Live chart widget not loadingCheck browser console for NFusion CDN errors; widget config is account-level