Giter Site home page Giter Site logo

craft-currency's Introduction

Craft Currency

Convert currencies in Craft CMS 2.

Set-up

The plugin uses the fixer.io API for currency conversions. The service requires an access key to be provided, which can be acquired for free from the website.

Paid plans also have the option to specify requests are made over HTTPS, and the plugin settings add the ability to enable this option also.

Usage

  • from_currency: 3 letter currency symbol (defaults to 'EUR')
  • to_currency: 3 letter currency symbol (defaults to 'USD')
  • amount: amount in from_currency to convert from (defaults to 1)

{{ craft.currency.conversion(from_currency, to_currency, amount) }}

Example

{# Converts 79 Australian dollars to Malaysian Ringits. #}
{{ craft.currency.conversion('AUD', 'MYR', 79) }}
Result
236.4312

Craft currency filter

The currency plugin works well with the currency filter built into Craft.

{# Converts 426 Icelandic krona to Danish kroner, and formats it using currency filter. #}
{{ craft.currency.conversion('ISK', 'DKK', 426)|currency('DKK') }}
Result
DKK20.49

craft-currency's People

Contributors

mark-adigital avatar monachilada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

craft-currency's Issues

Craft v3 version

Hi

Are you interested in upgrading to craft cms V3?
If not, do you mind if I fork and give it a go?

Regards
Ben

Update plugin due to API changes

Hi,

Last week we had a site go down briefly due to the endpoint provided by fixer being updated and a new requirement that users of the API create an account.

In the short term I've patched this by updating services/CurrencyService.php with the following edits to lines 18 and 19:

$url = '/latest?base='.$from.'&symbols='.$to.'&access_key=ACCESS_KEY'; $client = new \Guzzle\Http\Client('http://data.fixer.io/api');

For the moment I've hardcoded the access key, but it would obviously be more useful if this could be a plugin setting. It might also be worth having an additional setting to specify https or not as the secure endpoint is now only available with a paid plan.

If these updates could be made and released that would be great.

Thanks,

Mark

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.