Skip to content

Example plugin to show how to update currency rates from an API

Notifications You must be signed in to change notification settings

pixelandtonic/CommerceCurrencyRates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Commerce Currency Rates

This is an example plugin that enables commerce currency rates to be updated with live rates from the fixer.io api.

Installation & Setup

  1. Copy the currencyrates folder into your craft/plugins folder.

  2. Click install on the plugin within settings > plugins

  3. Make a currencyrates.php file in your craft/config/ directory with the following:

<?php
return [
    'secret' => '123'
];
  1. Replace 123 from the file above with a long unique password or hash.

  2. Set up a cron job to hit this url:

http://yourdomain.dev/actions/currencyRates/update/rates?code=123
  1. Notice the code=123. Replace 123 with the unique password that you populated in step 4.

  2. Set the cron to hit that url periodically. The example below is a cron command which hits the url every 24 hours at midnight:

0 0 * * * wget -O - http://yourdomain.dev/actions/currencyRates/update/rates?code=123 >/dev/null 2>&1

You can manually visit the url to test the rates are updated correctly before setting up your cron job.

Data Source

The plugin uses the http://fixer.io/ api for the live rates.

Fixer.io is a free JSON API for current and historical foreign exchange rates published by the European Central Bank.

The rates are updated daily around 4PM CET.

Releases

No releases published

Packages

No packages published

Languages