voskobovich/yii2-price-formatter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

voskobovich/yii2-price-formatter

Composer 安装命令:

composer require voskobovich/yii2-price-formatter

包简介

Component for converting price for Yii2

README 文档

README

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

License Latest Stable Version Latest Unstable Version Total Downloads

Support

GutHub issues.

See example

The example of the USD.

Converts 3.99 dollars => 399 cents

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

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

Converts 399 cents => 3.99 dollars

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

Converts 399 cents => 3 dollars, 99 cents

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

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

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

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

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;
            }
        ]
    ]
]
``

统计信息

  • 总下载量: 103
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固