Download the PHP package banulakwin/laravel-pricing without Composer

On this page you can find all versions of the php package banulakwin/laravel-pricing. 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 laravel-pricing

Laravel Pricing (banulakwin/laravel-pricing)

Latest Version on Packagist Tests Total Downloads

Portable Laravel package: a small rule-based pricing engine with config toggles, injectable coupon validation, and defaults for coupon (percent), tax, and flat shipping.


Requirements


Installation

Registration is automatic via Composer extra.laravel.providers:

Optional facade alias: Pricing → Banulakwin\Pricing\Facades\Pricing.

Publish configuration (optional):

Publish migrations (optional):


Configuration

Config key Purpose
pricing.rules Booleans: coupon, tax, shipping (your app branches when building the engine).
pricing.user_model Class string for the user model, used for coupon user restrictions and first-time validation.
pricing.user_orders_relation Method name on the user model (e.g., orders) to verify first_time_only coupon eligibility.
pricing.user_orders_scope Optional scope name (e.g., captured) applied to the orders query. Set to null to use the relation as-is.
pricing.tax.rate Default tax rate for TaxRule (overridable in constructor).
pricing.shipping.flat Default flat shipping for ShippingRule (overridable in constructor).
pricing.auto_rules Optional list of rule class names to resolve with app($class) and attach to the engine.

Environment: PRICING_TAX_RATE, PRICING_SHIPPING_FLAT (see config/pricing.php).


Usage

Basic Pricing

Line Item Format

Conditional Rule Registration


Architecture

Engine Flow

  1. calculate() builds PriceContext, sets subtotal / initial total from line items (price × qty).
  2. Each registered rule mutates discount, tax, shipping, and total in order.

Rule order matters — compose rules explicitly in your app.

Contracts


Coupon Types

Global Coupon

Applies to all items in the cart (empty items relation).

Targeted Coupon

Applies only to specific items via coupon_items pivot table.

User-Restricted Coupon

Only redeemable by specific users via coupon_users pivot table.

First-Time Only Coupon

Validates that the user has no prior orders via the configured user_orders_relation. Guest users are allowed through during preview — server-side checkout re-validates once authenticated.

Once Per User Coupon

Prevents a user from redeeming the same coupon code more than once. Checks past orders for the coupon code via the configured user_orders_relation. Guest users are allowed through during preview — server-side checkout re-validates once authenticated.

Configurable Order Scope

When validating first_time_only or once_per_user, an optional scope can be applied to the orders query via pricing.user_orders_scope (e.g., captured to only count paid orders). Leave it null to use the relation as-is, or define your relation to return only the orders you want counted.


Testing


Changelog

See CHANGELOG.md for details.


Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/your-feature)
  3. Run composer quality to ensure tests and style pass
  4. Commit and push
  5. Open a pull request

Package layout (reference)


License

MIT — see LICENSE for details.


All versions of laravel-pricing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.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 banulakwin/laravel-pricing contains the following files

Loading the files please wait ...