ownego/laravel-shopify-currency

Currency converter using Shopify's currencies cdn file

1.0.0 2021-12-13 08:15 UTC

This package is auto-updated.

Last update: 2024-11-13 14:40:07 UTC


README

This package created for convert between 2 currencies by using currencies.js file provided by Shopify.

Installation

  1. Install package

    composer require ownego/laravel-shopify-currency
    
  2. Optional: add the service provider

    'providers' => [
       // ...
       Ownego\LaravelShopifyCurrency\LaravelShopifyCurrencyServiceProvider::class,
    ],
  3. Optional: publish config

    php artisan vendor:publish --provider=Ownego\LaravelShopifyCurrency\LaravelShopifyCurrencyServiceProvider
    
  4. Optional: add facade

    'alias' => [
       // ...
       'ShopifyCurrency' => Ownego\LaravelShopifyCurrency\Facades\ShopifyCurrency::class,
    ],

Usage

  1. Convert
    use Ownego\LaravelShopifyCurrency\Facades\ShopifyCurrency;
    
    $result = ShopifyCurrency::convert(100, 'eur', 'usd');
  2. Get rate
    use Ownego\LaravelShopifyCurrency\Facades\ShopifyCurrency;
    
    $result = ShopifyCurrency::rate('eur', 'usd');

Command

If you want to manually update currencies from cache, then run:

php artisan shopify-currency:cache