Search by

fluffydiscord / sylius-customer-group-rules-bundle

FluffyDiscord

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

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-09 08:31 UTC

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

Install

composer require fluffydiscord/sylius-customer-group-rules-bundle

Usage

  1. config/bundles.php
 return [
     // ...
+    FluffyDiscord\SyliusCustomerGroupRulesBundle\SyliusCustomerGroupRulesBundle::class => ['all' => true],
 ];
  1. 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;
 }
  1. src/Entity/Payment/PaymentMethod.php, and the same in src/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;
 }
  1. 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\Migrations under your namespace in sylius_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_methods or sylius.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