Download the PHP package armezit/lunarphp-purchase-limit without Composer

On this page you can find all versions of the php package armezit/lunarphp-purchase-limit. 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 lunarphp-purchase-limit

Lunar Purchase Limit Addon

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

The Purchase Limit addon for Lunar allows you to define complex purchase limitation scenarios in your Lunar store.

Features

You can define a criteria for each rule. Currently, you are able to define purchase limits for:

Each purchase limit rule allows you to restrict either quantity, amount (total sum), or both of them.

Quick Setup

Install the Lunar Purchase Limit via composer:

Run the migrations with:

Usage

By default, after quick setup, you can start to define purchase limits on products and customers. There is also a detailed installation guide, in case you need more customization.

Detect Violation of Defined Limitations

The package throws a child type of Lunar\Exceptions\Carts\CartException exception, each time a violation of defined limits detected.

Typically, you want to catch these exceptions during create order process:

Product Purchase Limit (Slot)

The Product Purchase Limit slot will let you define limitations for a specific product.

In the following example, we have defined limitation rules for product A:

  1. Any customer is allowed to purchase at most 10 units of the product in each Week.
  2. Customers of Retail group are allowed to purchase at most 2000 total sum of the product in Each Purchase. So, for example, if price of product is $500, they can only purchase up to 4 unit of product A in each order.

BY default, you will find this slot in bottom of the product edit page. However, you can change this default position in config file.

Customer Purchase Limit (Slot)

The Customer Purchase Limit slot will let you define limitations for a specific customer or customer group.

TODO: Not Yet Implemented !

Advanced Usage

Architecture

The primary component is Rule classes, which check defined limitations (stored in database) and throw exception if a violation of rule detected.

There are two kinds of rules which implement either CartRuleInterface or CartLineRuleInterface contracts.

Each rule perform only a unique type of checks.

For example, CustomerProductLimit rule only checks purchase limits of a specific customer on a specific product.

While CustomerLimit rule only checks purchase limits of a specific customer on any product, and ProductLimit rules only checks purchase limits of any customer on a specific product; And so on.

These rules are injected into the Cart/CartLine modifiers pipelines.

So, everytime you try to call CreateOrder action, these rules execute one by one and throw exception if detect violation of defined limitations.

Complex Rules

Although there is Hub slots for defining typical limitations, nothing prevents you to compose more complex rules by saving purchase limits directly in database.

Take a look at the PurchaseLimit Model.

Extend

In addition, you can extend/modify business logic by implementing CartRuleInterface and/or CartLineRuleInterface contracts and inject them into the modifier pipelines.

After implementing a new CheckVeryComplexLimit rule, add it to the corresponding pipeline in config file:

or

Installation

Quick Setup covers the essential installation steps. This section, however, is a detailed installation procedure, containing all optional parts.

You can install the package via composer:

Migrations

Optionally, publish the migrations:

Run the migrations with:

::: tip Table names are configurable. See the config file. :::

Config

You can publish the config file with:

This is the contents of the published config file:

Translations & Views

Optionally, you can publish the translations and views using

Service provider

By default, this package automatically register it`s service providers when it is installed.

If for any reason you prefer to register them manually, you should add the package service providers into your laravel application's config/app.php file.

The PurchaseLimitServiceProvider bootstrap primary package features, while the PurchaseLimitHubServiceProvider is used to register some Slots to be used in Lunar Admin Hub.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of lunarphp-purchase-limit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
livewire/livewire Version ^2.0
spatie/laravel-package-tools Version ^1.9.2
lunarphp/lunar Version ^0.8
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 armezit/lunarphp-purchase-limit contains the following files

Loading the files please wait ....