brille24 / tierprice-plugin
A plugin that allows to add tierprices to Sylius
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 44
Watchers: 5
Forks: 39
Open Issues: 7
Type:sylius-plugin
Requires
- php: ^8.0
- sylius/sylius: ^1.11
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- friendsofsymfony/oauth-server-bundle: ^1.6 || >2.0.0-alpha.0 ^2.0@dev
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.99
- phpstan/phpstan-doctrine: 0.12.33
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-webmozart-assert: 0.12.12
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^5.4
- symfony/debug-bundle: ^5.4
- symfony/dotenv: ^5.4
- symfony/intl: ^5.4
- symfony/web-profiler-bundle: ^5.4
- vimeo/psalm: 4.7.1
- 3.0.2
- 3.0.1
- 3.0.0
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.2
- 2.3.1
- 2.3.0
- 2.3.0-ALPHA
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- dev-master / 1.12.x-dev
- 1.8
- v1.7.4
- v1.7.3
- v1.7.2.2
- v1.7.2.1
- v1.7.2
- v1.7.1
- v1.7
- v1.6
- v1.5.0
- v1.4.5
- v1.4.1
- v1.4
- 1.3.1
- v1.3
- v1.2
- v1.1
- 1.0
- v0.10
- v0.9
- v0.8
- v0.7
- v0.6
- v0.5
- v0.4
- 0.3
- dev-fixing_empty_tierprices
- dev-fixing_master
- dev-fixing_migration_prepend
This package is auto-updated.
Last update: 2024-12-13 13:10:19 UTC
README
Sylius Tier Price Plugin
This plugin adds tier pricing to Sylius one product has different prices based on the quantity.
Installation
- Install the bundle via composer
composer require brille24/sylius-tierprice-plugin
- Register the bundle in your
bundles.php
:
return [ //... Brille24\SyliusTierPricePlugin\Brille24SyliusTierPricePlugin::class => ['all' => true], ];
- Add the
config.yml
to your localconfig/config.yml
imports: ... - { resource: '@Brille24SyliusTierPricePlugin/Resources/config/config.yml'}
- For API functionality add the bundle's
routing.yml
to the localapp/config/routing.yml
... brille24_tierprice_bundle: resource: '@Brille24SyliusTierPricePlugin/Resources/config/routing.yml'
- Go into your ProductVariant class and add the following trait and add one method call to the constructor
class ProductVariant extends BaseProductVariant implements \Brille24\SyliusTierPricePlugin\Entity\ProductVariantInterface { use \Brille24\SyliusTierPricePlugin\Traits\TierPriceableTrait; public function __construct() { parent::__construct(); // Your contructor here $this->initTierPriceableTrait(); // "Constructor" of the trait } protected function createTranslation(): ProductVariantTranslationInterface { return new ProductVariantTranslation(); } }
- Finally update the database, install the assets and update the translations:
bin/console doctrine:schema:update --force bin/console assets:install bin/console translation:update <locale> --force
Integration
- This bundle decorates the
sylius.calculator.product_variant_price
service. If you wish to change that, you could register a compiler pass. - This bundle decorates the
sylius.order_processing.order_prices_recalculator
service. If you wish to use your own order processor or change its priority, you could register a compiler pass.
Usage
First of all you have to set up a product with as many variants as you want. Then in each of these variants you can set the tier pricing based on the channels. The table automatically sorts itself to provide a better overview for all different tiers, you configured.
In the frontend the user will see a nice looking table right next to the "add to cart" button that shows the discount for the different tiers like so:
Creating data
You can easily create the tier prices with fixtures like that.
sylius_fixtures: suites: my_suite: fixtures: tier_prices: options: custom: - product_variant: "20125148-54ca-3f05-875f-5524f95aa85b" channel: US_WEB quantity: 10 price: 5
For this the products need to be created first and the product variant must also exist.