Search by

leowebguy / craft-currency-converter

leowebguy

Craft plugin to convert currency using API & local storage

Package info

github.com/leowebguy/craft-currency-converter

Type:craft-plugin

pkg:composer/leowebguy/craft-currency-converter

Statistics

Installs: 2 721

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 1

2.0.2 2024-07-31 12:48 UTC

This package is auto-updated.

Last update: 2026-10-31 13:30:51 UTC


README

Craft plugin to convert currency using API & local storage.

Requirements

This plugin requires:

  • Craft CMS: ^5.0.0
  • PHP: ^8.2 || ^8.3 || ^8.4 || ^8.5

Installation

Open your terminal and go to your Craft project:

cd /path/to/project

Then tell Composer to load the plugin:

composer require leowebguy/craft-currency-converter -w

In the Control Panel, go to Settings → Plugins and click the Install button for Currency Converter.

Configuration

  1. Go to RapidAPI Currency Converter and obtain your API Key.
  2. In the Control Panel, go to Settings → Currency Converter and paste your API Key.
  3. Alternatively, define an environment variable in your .env file:
    CC_KEY=aaa123bbb234
    And reference it in the plugin settings as $CC_KEY.
  4. Choose your preferred cache duration (1 to 24 hours). Rates are stored in Craft's storage folder (storage/currency/) to minimize API requests.

screenshot1

Usage

The plugin exposes currency conversion helper methods via Twig:

{# Passing dynamic entry field value #}
{% set amount = craft.entries.section('mySection').one().numberField %}
{{ craft.currency.conversion('USD', 'EUR', amount) }}
{# Passing an integer or float #}
{{ craft.currency.conversion('USD', 'EUR', 23.50) }}
{# Passing a numeric string #}
{{ craft.currency.conversion('USD', 'EUR', '23') }}

Development & Testing

# Run PHPStan static analysis (Level 8)
composer phpstan

# Run PSR-12 code style check
composer pint-test

# Auto-fix code style issues
composer pint

# Run Rector Craft 5 migration checks
composer rector

License

MIT License. See LICENSE.md for details.