2017 © Pedro Peláez
 

yii2-widget yii2-price-formatter

Component for converting price for Yii2

image

voskobovich/yii2-price-formatter

Component for converting price for Yii2

  • Tuesday, May 10, 2016
  • by voskobovich
  • Repository
  • 1 Watchers
  • 6 Stars
  • 60 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Yii2 Price Formatter

This component converts currency values (prices) between fixed-point representation (int as number of cents) and floating point representation (float as dollars and cents)., (*1)

License Latest Stable Version Latest Unstable Version Total Downloads, (*2)

Support

GutHub issues., (*3)

See example

The example of the USD., (*4)

Converts 3.99 dollars => 399 cents, (*5)

Yii::$app->get('priceFormatter')->toStore(3.99); // input float
Yii::$app->get('priceFormatter')->toStore('3,99'); // input string
// Result: 399

Converts 3 dollars 99 cents => 399 cents, (*6)

Yii::$app->get('priceFormatter')->toStoreByParts(3, 99);
// Result: 399

Converts 399 cents => 3.99 dollars, (*7)

Yii::$app->get('priceFormatter')->toEdit(399);
// Result: 3.99

Converts 399 cents => 3 dollars, 99 cents, (*8)

Yii::$app->get('priceFormatter')->toEditByParts(399);
// Result array:
[
    0 => 3,
    1 => 99
]

Converts 399 cents => $3.99 (with currency symbol ), (*9)

Yii::$app->get('priceFormatter')->toView(399);
// Result: $3,99

Installation

The preferred way to install this extension is through composer., (*10)

Either run, (*11)

php composer.phar require --prefer-dist voskobovich/yii2-price-formatter "~1.0"

or add, (*12)

"voskobovich/yii2-price-formatter": "~1.0"

to the require section of your composer.json file., (*13)

Usage

Configuration component in your app config file
``` [ ... 'components' => [ 'priceFormatter' => [ 'class' => 'voskobovich\price\components\PriceFormatter', // 'currencyCode' => 'USD', 'currencyCode' => function($component) { return Yii::$app->user->identity->currency_code; } ] ] ] ``, (*14)

The Versions

10/05 2016

dev-master

9999999-dev https://github.com/voskobovich/yii2-price-formatter

Component for converting price for Yii2

  Sources   Download

MIT

The Requires

 

component yii2 formatter currency price

10/05 2016

1.1.2

1.1.2.0 https://github.com/voskobovich/yii2-price-formatter

Component for converting price for Yii2

  Sources   Download

MIT

The Requires

 

component yii2 formatter currency price

07/04 2016

v1.1.1

1.1.1.0 https://github.com/voskobovich/yii2-price-formatter

Component for converting price for Yii2

  Sources   Download

MIT

The Requires

 

component yii2 formatter currency price

01/02 2016

v1.1.0

1.1.0.0 https://github.com/voskobovich/yii2-price-formatter

Component for converting price for Yii2

  Sources   Download

MIT

The Requires

 

component yii2 formatter currency price

30/01 2016

v1.0.0

1.0.0.0 https://github.com/voskobovich/yii2-price-formatter

Component for converting price for Yii2

  Sources   Download

MIT

The Requires

 

component yii2 formatter currency price