# ZPT Metals

> Display live and historical precious-metal rates (gold, silver, platinum and 36 more) with shortcodes, and auto-price WooCommerce products from them.

**No longer maintained.** ZPT Metals is retired. Version 1.2.1 (January 2023) is the final release: no further updates, fixes or support will be published, and compatibility with current WordPress, WooCommerce and metals-api.com versions is not verified. The documentation stays here for existing installations.

- **Type:** Plugin (WordPress plugins)
- **Version:** 1.2.1, released 9 Jan 2023
- **Requires:** WordPress 5.0+, metals-api.com API key
- **Tested with:** WordPress 6.1.12
- **WordPress.org:** https://wordpress.org/plugins/zpt-metals/
- **Documentation:** https://developers.zactonz.com/wordpress/plugins/zpt-metals/

## Overview

ZPT Metals displays precious- and industrial-metal rates on a WordPress site in the currency you choose. Rates come from [metals-api.com](https://metals-api.com) through your own API key. A shortcode renders the latest or a historical rate anywhere the editor is available, and WooCommerce products can be priced automatically from a chosen metal.

### Features

- Latest metal rates, refreshed on a schedule you set.
- Shortcode to display the latest or a historical rate in any post or page.
- Rates in any supported currency (USD, GBP, CAD and others).
- Cron job option with custom timing, so the API is called at most once per interval and visitors are served cached rates.
- WooCommerce support, including automatic product pricing tied to a metal.

### Supported metals

Gold, silver, platinum, palladium, rhodium, ruthenium, copper, aluminium, nickel, zinc, tin, cobalt, iridium, lead, iron ore, uranium, bronze, magnesium, osmium, rhenium, indium, molybdenum, tungsten, steel (SC, RE, HR), LBMA gold, platinum and palladium (AM and PM fixes), and LME aluminium, copper, zinc, nickel, lead and tin.

### Disclaimer

This plugin relies on a third-party service, metals-api.com. You need an API key from that service, and the plugin only fetches rates on behalf of that key. Read metals-api.com's privacy policy before use.

## Shortcode

Use `[zpt-metals]` in any post, page or widget that accepts shortcodes. Combine the attributes below as needed.

| Attribute | Required | Description |
|---|---|---|
| `type` | Yes | Which metal to show, for example `gold`, `silver`, `platinum`, `palladium`, `rhodium` or `ruthenium`. Any metal listed on the Overview tab is accepted. |
| `base` | No | Currency for the rate, such as `USD` or `GBP`. Defaults to the currency chosen in the plugin settings. |
| `price-round` | No | Number of digits after the decimal point. Any integer. |
| `date` | No | Show the rate for a specific day instead of the latest. Format `YYYY-MM-DD`. |
| `date-format` | No | How the rate's date is printed, using PHP date format characters, for example `Y-m-d` or `m-d-Y`. |

### Examples

Latest gold rate in the default currency:

```text
[zpt-metals type="gold"]
```

Silver in British pounds, rounded to two decimals:

```text
[zpt-metals type="silver" base="GBP" price-round="2"]
```

Platinum on a given day, with the date shown as day-month-year:

```text
[zpt-metals type="platinum" date="2022-03-01" date-format="d-m-Y"]
```

### WooCommerce auto pricing

Edit a product, open the **Auto pricing** tab under Product data, enable it and choose a metal. The product price then follows that metal's rate at each scheduled refresh.

## Installation

> ZPT Metals is retired. These steps are kept for existing users; new installations are not recommended.

1. Install from **Plugins › Add New** by searching for **ZPT Metals**, or upload the extracted plugin folder to `/wp-content/plugins/`.
2. Activate it from the **Plugins** menu.
3. Open the plugin's settings page and enter your [metals-api.com](https://metals-api.com) API key.
4. Choose the default currency and the refresh interval. The plugin calls the API once per interval and serves cached rates in between.

## FAQ

### Is an API key required?

Yes. A metals-api.com key is required to fetch rates. The plugin does nothing without one.

### Does the plugin handle API rate limits?

Yes. It requests fresh rates only after the interval set in its settings has passed since the last run, saves them in the database, and serves the saved rates to visitors until the next run.

### Is the plugin still supported?

No. ZPT Metals is retired and receives no further updates, fixes or support. The last release is 1.2.1 from January 2023.

## Changelog

### 1.2.1 — 9 January 2023 (final release)

- Added support for 10 more metals from metals-api.

### 1.2.0

- Added WooCommerce support.
- Added product auto pricing in the WooCommerce product data tabs.
- Added a cron job option.
- Bug fixes.

### 1.1.0

- Added 17 new metals.
- Added a carat attribute for gold.
- Bug fixes.

### 1.0

- Initial release.
