Download the PHP package mohammadmehrabani/conditional-coupon without Composer

On this page you can find all versions of the php package mohammadmehrabani/conditional-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 conditional-coupon

conditional coupon code

With this package, you can add both simple and conditional discount coupon features to your application. You can develop your own custom conditions, which will be automatically checked when a discount coupon is applied. If a condition is violated, an error will be returned and the coupon will not be allowed to be used by the user.

Installation

You can install the package via composer:

You can publish and run the migrations with:

You can publish the config file with:

This is the contents of the published config file:

If you want any conditions to be checked when applying a discount coupon, simply create a class that implements \MohammadMehrabani\ConditionalCoupon\CheckConditionAbstract and add it to the conditional-coupon.php config file along with a title for the condition. No further action is needed—it's that simple.

add to config file:

Usage

Implementing the CRUD for discount coupons—and adding conditions if needed—is up to you. Once created, you can simply use the discount coupon feature for your orders as shown in the example below.

Listing Available Check Classes

You can retrieve all available Check classes using the GetCustomConditions class. Each Check class has a title property which is wrapped in __() for translation. This list can be used to populate the select box when creating discount coupons.

create coupon with conditions

create coupon without conditions

use coupon for order

Discount Logic

The package supports two types of discount fields:

Rules

  1. Single Field Case

    • If only one of the fields is provided, the discount will be applied based on that field.
  2. Both Fields Case
    • If both discount_percentage and discount_amount are provided:
      • The discount value is first calculated from the discount_percentage.
      • If the calculated percentage discount is greater than the fixed discount_amount, then the fixed amount will be applied.
      • If the calculated percentage discount is less than or equal to the fixed discount_amount, then the percentage-based discount will be applied.

Example

Calculation:

Testing

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of conditional-coupon with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^9.0||^10.0||^11.0||^12.0
illuminate/filesystem Version ^9.0||^10.0||^11.0||^12.0
illuminate/contracts Version ^9.0||^10.0||^11.0||^12.0
illuminate/database Version ^9.0||^10.0||^11.0||^12.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 mohammadmehrabani/conditional-coupon contains the following files

Loading the files please wait ...