Download the PHP package tmonier/sylius-tier-pricing-plugin without Composer

On this page you can find all versions of the php package tmonier/sylius-tier-pricing-plugin. 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 sylius-tier-pricing-plugin

Sylius Tier Pricing Plugin

Français : README.fr.md

Build

Volume (tier) pricing for Sylius 2: "from 10 pieces, 9.00 € per piece".

Sylius 2 has one price per variant and channel. Quantity price breaks are a basic need of wholesale and B2B shops (and of many consumer shops), but the open source plugins that did it target Sylius 1.

This plugin adds price break rules per channel, customer group, product or variant, applies them in the cart, and shows them on product pages and in the cart as conditional prices, free and open source.

Features

Need What the plugin does
Lower the unit price from a quantity Rules: from N pieces (N >= 2), a fixed unit price or a percentage off the regular price, per channel, optionally for one customer group, with optional start and end dates.
Target what you sell A rule applies to one variant, to every variant of a product or (1.1) to every product of a taxon and of its children (through any of the product's taxons, not only the main one). The threshold counts the cart line, every variant of the product (mix and match: 6 red + 4 blue = 10) or (1.1) every product of the taxon (4 drills + 6 saws = 10 tools).
Clear precedence (1.1) Variant and product rules first, else the rules of the deepest taxon of the product, else the regular price.
Predictable results The most specific level that has rules for the customer wins (variant/product, else the deepest taxon, see How prices are computed); within it, the lowest unit price among the rules reached wins (specificity only breaks ties). The price never goes up with the quantity, and the product table shows what the cart charges for the line (taxon-basis tiers also count the other products of the taxon in the cart).
Correct carts An order processor (priority 44) changes the unit price of the cart line; cart promotions, shipping and taxes are computed on it. Locked (immutable) lines, e.g. negotiated quote lines, are left untouched.
No double discount, or a chosen one Per rule (1.1): best of the tier price and the catalog promotion price (default, 1.0 behaviour; a percentage is computed on the regular price), on top (the percentage is taken off the promotion price) or skip if promoted (no tier price for a variant with a catalog promotion). The channel pricing minimum price is a floor; cart promotions always apply on top of the tier price.
Show the prices Tier table on the product page (re-rendered when the variant changes), "add 3 more to pay 8.00 € per piece" nudges on the product page and in the cart, "volume price from 10 pieces" on cart lines.
Stay on the right side of price rules Tiers are shown as conditional prices: no struck-through price (also in the shop API: in consumer channels originalUnitPrice of a tier line is the tier price and its tmonier_tier_price adjustment has a zero amount), no "-x %" in consumer channels by default, amounts in the tax convention of the Sylius prices next to them, labelled (see Legal notes).
Manage the rules Admin grid (Catalog > Volume pricing), rule form, Volume pricing tab on the product page.
Bulk changes tmonier:tier-pricing:import / :export (CSV, upsert or replace, dry run, all or nothing).
Headless Admin API CRUD /api/v2/admin/tier-price-rules, shop API GET /api/v2/shop/product-variants/{code}/tier-prices.

Also included: translations in English, French, German, Spanish, Italian, Dutch and Polish; Twig Hooks everywhere; tagged cache per product, channel and customer group; demo fixture; MySQL, MariaDB and PostgreSQL support.

Screenshots

Requirements

Version
PHP 8.2+ (Sylius 2.2), 8.3+ (Sylius 2.3)
Sylius 2.2.9+, 2.3
Symfony 6.4, 7.4 (Sylius 2.2); 6.4, 7.4, 8.0 (Sylius 2.3, Symfony 8 needs PHP 8.4)

Sylius 2.2.9 is the floor because the plugin changes cart prices: earlier 2.2 releases are affected by GHSA-2rv4-pjmm-7fxf and GHSA-vv4h-q2x8-74g4 (payment requests).

Installation

  1. Require the package:

  2. Register the bundle in config/bundles.php (Symfony Flex does it automatically once a recipe exists):

  3. Import the configuration in config/packages/tmonier_sylius_tier_pricing.yaml:

  4. Import the admin routes in config/routes/tmonier_sylius_tier_pricing.yaml:

    The API operations are registered with the Sylius API (/api/v2) automatically.

  5. Run the migrations (a table and a CHECK constraint):

Configuration

Customer group rules. In shop requests (shop pages and shop API), group rules apply only when the order's customer is the signed-in customer. At a guest checkout, Sylius attaches an existing customer (without shop account, common for B2B customers created in the admin) to the order from the e-mail typed by the visitor: anyone knowing that e-mail would get the group prices. Everywhere else (admin, admin API, console, message consumers: orders created on behalf of a customer, quote conversions, imports) the group of the order's customer applies. Set group_prices_for_guests: true to apply group rules in shop requests too.

Taxes. Sylius has no "prices with / without taxes" setting per channel: a channel price includes the tax or not depending on the tax rate (includedInPrice) of the variant. Tier amounts are shown as stored, in the same convention as the Sylius product price and cart unit price next to them, with an "including / excluding taxes" label taken from the rate of the variant in the channel default tax zone (no label when it is unknown: no default tax zone, no rate). Consumer channels in the EU should store prices with taxes (rates includedInPrice).

The rules of a product are cached in the cache.tmonier_tier_pricing pool (tags: product, channel, customer group; adapter cache.app by default). Any rule saved through Doctrine (admin, API, import) invalidates its product in that pool. With several web or worker nodes, cache.app must be shared (e.g. Redis), or configure the pool on a shared tag-aware adapter, or set cache_ttl: 0: with a local filesystem cache, the other nodes keep the old rules until cache_ttl expires.

Rules

Field Values
Channel required; amounts are in its base currency
Customer group empty = everybody
Applies to product (every variant), variant or taxon (every product of the taxon and of its children, 1.1)
Quantity counted line (the variant), product (every variant of the product, mix and match) or taxon (every product of the taxon of the rule, taxon rules only, 1.1)
With catalog promotions (1.1) best_of (default), on_top or skip_if_promoted
From quantity 2 to 1,000,000
Price percentage_off (of the regular price, before catalog promotions) or fixed_unit_price (same tax convention as the channel prices, at most 10,000,000.00)
Enabled, starts at, ends at the end is excluded; dates are stored in the PHP default timezone (UTC recommended, as for Sylius), a date given with another offset keeps its instant

One rule per channel, customer group, target and threshold over a period: checked by the application (a unique index would treat the "everybody" rules as distinct on MySQL, MariaDB and PostgreSQL < 15).

CSV import and export

The last two columns are new in 1.1 (taxon: code of the taxon of a taxon rule; cumulation: empty = best_of); files with the 12 columns of 1.0 are still imported.

value is an amount (6.40) for a fixed price and a percentage (7.5) for a percentage off. enabled is 1, true, yes, 0, false, no or empty (enabled); anything else is an error. Dates are ISO 8601; their offset is kept (converted to the application timezone). A leading UTF-8 byte order mark (Excel "CSV UTF-8") is ignored. Two lines for the same rule are reported (duplicate of line N). upsert updates the rule with the same channel, group, target, threshold and dates, or creates it; replace deletes every rule (of --channel) first. The whole file runs in one transaction: one invalid line and nothing is saved (every error is listed with its line number). The entity manager is cleared every 500 lines.

Extension point

Implement Tmonier\SyliusTierPricingPlugin\OrderProcessing\TierPriceExemptionCheckerInterface (autoconfigured) to keep some cart lines out of tier pricing (they keep their price and do not count in the quantity of their product).

Customisation

Hook Content
sylius_shop.product.show.content.info.summary.add_to_cart → tmonier_tier_pricing Tier table and nudge (between quantity and button)
sylius_shop.cart.index.content.form.sections.general.items.body → item Core product cell + tier applied + nudge under the product (replaces the core template)
sylius_admin.product.update.content.form.side_navigation / .sections → tmonier_tier_pricing Volume pricing tab of the product form
tmonier_tier_pricing_admin.tier_price_rule.create\|update.content.form.sections.general → fields Rule form layout

Templates can be overridden in templates/bundles/TmonierSyliusTierPricingPlugin/. Twig functions: tmonier_tier_pricing_table(variant), tmonier_tier_pricing_cart_table(item), tmonier_tier_pricing_tax_convention(variant), tmonier_tier_pricing_item_tier(item). In PHP, TierPriceCalculatorInterface::quote() / table() give the tier price of a variant for given quantities.

How prices are computed

Legal notes

This is not legal advice; check with your counsel, especially for consumer (B2C) channels in the EU.

Limitations

Development

The functional and integration tests need a test database with the Sylius fixtures (admin sylius, [email protected], a channel with hostname localhost and a default tax zone). tests/TestApplication/.env.test uses the CI credentials (root:root); with the local Docker MySQL, override it in tests/TestApplication/.env.test.local:

B2B demo

This plugin is used in the Sylius B2B demo: a Sylius 2.3 shop with fictitious sample data where the B2B plugins work together. The source code, setup and fixtures of the demo are in that repository.

The demo is an example, not a production setup.

License

MIT. See LICENSE.


All versions of sylius-tier-pricing-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
sylius/sylius Version ^2.2.9 || ^2.3
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 tmonier/sylius-tier-pricing-plugin contains the following files

Loading the files please wait ...