Download the PHP package zgldh/discount-and-coupon without Composer

On this page you can find all versions of the php package zgldh/discount-and-coupon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package discount-and-coupon

zgldh/discount-and-coupon

优惠活动、折扣计算器

Build Status

定义

  1. 折扣活动,通常用于店铺对所有消费者的活动。
  2. 优惠券,通常属于一个特定的消费者的特权。
  3. 以上两者在下文统称“benefit 权益”
  4. zgldh\DiscountAndCoupon\Benefit::class 是可享用的权益的基类,用于定义一系列折扣活动、优惠券的类型。注意是定义类型而不是实例。
  5. priority 表示该权益的判断优先级,数值越高越优先判断。

功能

  1. 输入“权益(benefit)”和一些货品,即可计算出最终价格。
  2. 可以得出每一个货品参与了哪些 权益。

用法

先给个感性认识。

如何定义店铺折扣活动 Discount

1. 定义店铺的“满减活动”:

上面我们定义了 FlatDiscountWhenPurchaseExceed 类,用于描述“满减”这一类活动。

然后我们新建了 3 个该类的对象,分别代表满20减2, 满50减10, 满100减30 这三种活动。

注意 priority 属性, 它决定了 Calculator 在尝试应用折扣时的判断顺序。由于默认以上三种活动同属于“满减”活动,且只能应用其中一种(请参考 Benefit 类的源码中对 $group 的说明)。所以我们让优惠额度最大的优先级最高,以便总是能帮客户享用最大的优惠力度。

2. 定义店铺的“迎中秋早餐8折”活动,不与其他活动同享:

3. 定义“新品促销,XX酸奶买一送一” 活动,不与其他活动同享。

下列代码是以减价实现本促销活动,会影响本次订单最终价格。

下列代码是以赠送货品实现促销活动,不会影响本次订单最终价格,但会增加商品。

如何定义优惠券 Coupon

其实优惠券和折扣活动逻辑上没有区别,请在您具体的业务代码里,删掉使用过的优惠券。

1. 定义代金券

2. 定义 “饮料升级优惠券”

能把订单内的某种饮料的一件商品替换成更贵的饮料。 本质是替换商品,所以你可以任意定义规则。


All versions of discount-and-coupon with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zgldh/discount-and-coupon contains the following files

Loading the files please wait ....