定制 megaads/coupon-utils 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

megaads/coupon-utils

Composer 安装命令:

composer require megaads/coupon-utils

包简介

Utilities for coupons

README 文档

README

Cài đặt:

composer require megaads/coupon-utils

Sau khi cài đặt xong thì cấu hình Service Provider class vào file app.php trong thư mục config của Laravel như sau:

Megaads\CouponUtils\CouponUtilsServiceProvider::class,

Sau đó thì chạy câu lệnh sau để tạo file cấu hình:

php artisan vendor:publish --provider="Megaads\CouponUtils\CouponUtilsServiceProvider" --tag=config --force

Sau khi chạy lệnh thì file cấu hình được tạo sẽ có nội dung như sau:

return [
    'free_shipping' => [
        'text' => ['free(.*)shipping'],
        'regex' => [
            'default' => '/#text/i'
        ],
        'value' => [
            'default' => ''
        ]
    ],
    'percent' => [
        'text' => ['off'],
        'regex' => [
            'default' => '/(\d+)% #text/i'
        ],
        'value' => [
            'default' => '#value%'
        ]
    ],
    'amount' => [
        'text' => ['off'],
        'regex' => [
            'default' => '/\$(\d+) #text/i'
        ],
        'value' => [
            'default' => '$#value'
        ]
    ],
];

Sau khi sửa file cấu hình xong thì chạy lệnh sau để clear cache:

php artisan config:cache

php artisan cache:clear

Thêm cái này vào 'aliases' => [] trong file app.php

'CouponUtils' => Megaads\CouponUtils\CouponUtils::class,

Rồi gọi cái này để lấy coupon promotion type :

$couponType = CouponUtils::detectCouponType($titleOfCoupon);

Hoặc gọi theo kiểu cũ không dùng file cấu hình ở trên:

$couponType = CouponUtils::getCouponType($titleOfCoupon);

Return trả về kiểu kiểu như sau

$retval = [
    'type' => 'deal',
    'value' => '',
];

Trong đó type có thể là : 'deal', 'percent', 'amout', 'free_shipping'

Value có thể là : '', '30', ...

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固