fluffydiscord / sylius-customer-group-rules-bundle
Customer group inheritance and allowed payment and shipping methods per group for Sylius.
Package info
github.com/FluffyDiscord/sylius-customer-group-rules-bundle
Type:sylius-plugin
pkg:composer/fluffydiscord/sylius-customer-group-rules-bundle
Requires
- php: >=8.4
- doctrine/dbal: ^3.9 || ^4.0
- doctrine/doctrine-migrations-bundle: ^3.4
- doctrine/orm: ^2.20 || ^3.6
- sylius/sylius: ^2.3
- symfony/form: ^7.4
- symfony/validator: ^7.4
- symfony/yaml: ^7.4
Requires (Dev)
- phpunit/phpunit: ^11.5 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-09 08:36:19 UTC
README
Customer group inheritance and allowed payment and shipping methods per group, for Sylius 2.
Requires PHP 8.4+ and Sylius 2.3.
Features
- Parent group — a group takes its parent's allowed methods
- Allowed methods — tick the payment and shipping methods a group may use
- Groups-only methods — hide a method from customers without a group
Install
composer require fluffydiscord/sylius-customer-group-rules-bundle
Usage
config/bundles.php
return [
// ...
+ FluffyDiscord\SyliusCustomerGroupRulesBundle\SyliusCustomerGroupRulesBundle::class => ['all' => true],
];
src/Entity/Customer/CustomerGroup.php
+use FluffyDiscord\SyliusCustomerGroupRulesBundle\Model\CustomerGroupRulesInterface; +use FluffyDiscord\SyliusCustomerGroupRulesBundle\Model\CustomerGroupRulesTrait; -class CustomerGroup extends BaseCustomerGroup +class CustomerGroup extends BaseCustomerGroup implements CustomerGroupRulesInterface { + use CustomerGroupRulesTrait; }
src/Entity/Payment/PaymentMethod.php, and the same insrc/Entity/Shipping/ShippingMethod.php
+use FluffyDiscord\SyliusCustomerGroupRulesBundle\Model\CustomerGroupsOnlyMethodInterface; +use FluffyDiscord\SyliusCustomerGroupRulesBundle\Model\CustomerGroupsOnlyMethodTrait; -class PaymentMethod extends BasePaymentMethod +class PaymentMethod extends BasePaymentMethod implements CustomerGroupsOnlyMethodInterface { + use CustomerGroupsOnlyMethodTrait; }
- Update the database. PostgreSQL and MySQL/MariaDB are supported.
bin/console doctrine:migrations:migrate
The admin forms and the checkout filter work right away.
Your own migrations that touch these columns must run after the bundle's. List
FluffyDiscord\SyliusCustomerGroupRulesBundle\Migrationsunder your namespace insylius_labs_doctrine_migrations_extra.
Parent group
Set the parent on the customer group form. The group then takes the parent's allowed methods. A parent can have its own parent. A group can't inherit from itself, directly or through other groups.
To apply the parent to your own rules, walk the groups:
foreach ($customerGroupMethodRules->getLineage($customer->getGroup()) as $group) { // the customer's group first, then its parents }
A parent with child groups can't be deleted.
Allowed methods
Tick the methods on the customer group form. Every group in the chain must allow a method, so a child can only narrow its parent's list.
| Group's list | Result |
|---|---|
| Empty | No limit from this group |
| Filled | Only the ticked methods |
Example: wholesale allows invoice and cash on delivery, its child allows invoice and card. The child sees invoice.
The limits apply wherever Sylius resolves methods: shop checkout, API, and your own code using
sylius.resolver.payment_methodsorsylius.resolver.shipping_methods.
Groups-only methods
Tick "Customer groups only" on the payment or shipping method form. Only a group that lists the method sees it, directly or through a parent.
| Customer | Ordinary method | Groups-only method |
|---|---|---|
| No group | Sees it | Doesn't see it |
| Group with no lists | Sees it | Doesn't see it |
| Group that lists it | Sees it | Sees it |
| Group that lists other methods | Doesn't see it | Doesn't see it |