PHPackages                             thelia/customer-group-module - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. thelia/customer-group-module

ActiveThelia-module

thelia/customer-group-module
============================

0.2.0(3mo ago)058651LGPL-3.0+PHP

Since Apr 24Pushed 3mo ago7 watchersCompare

[ Source](https://github.com/thelia-modules/CustomerGroup)[ Packagist](https://packagist.org/packages/thelia/customer-group-module)[ RSS](/packages/thelia-customer-group-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (9)Used By (1)

CustomerGroup
=============

[](#customergroup)

This module adds customer groups, in which you can put customers.

Installation
------------

[](#installation)

### Manually

[](#manually)

- Copy the module into the `/local/modules/` directory and make sure that the name of the module is CustomerGroup
- Activate it in your Thelia administration panel

### Composer

[](#composer)

Add it in your main Thelia composer.json file

```
composer require thelia/customer-group-module:~0.1

```

Configuration
-------------

[](#configuration)

Modules that use customer groups must define them in the `customer-group.xml` file in the module configuration directory. The groups will be created when the module is activated.

One the groups can be defined as the default group. All new customers will be automatically added to this group.

```

            Customer
            Basic customer

            Client
            Client de base

            VIP
            VIP customer !

            VIP
            Client VIP !

    customer

```

Events
------

[](#events)

Events should be used to perform actions related to customer groups.

The `CustomerGroup\Event\CustomerGroupEvents` class contains event name constants for this module. Event classes are also in the `CustomerGroup\Event` namespace.

### Add a customer to a group

[](#add-a-customer-to-a-group)

```
$event = new AddCustomerToCustomerGroupEvent();
$event->setCustomerId($myCustomer->getId());
$event->setCustomerGroupId($myGroup->getId());

$dispatcher->dispatch(
    CustomerGroupEvents::ADD_CUSTOMER_TO_CUSTOMER_GROUP,
    $event
);
```

Handler
-------

[](#handler)

The `customer_group.handler` service provide functions to check if a customer belongs to a group. See the `CustomerGroupHandler` class for available methods.

### Get handler (service)

[](#get-handler-service)

```
$groupHandler = $container->get("customer_group.handler");
```

### Get session customer's customerGroup info

[](#get-session-customers-customergroup-info)

```
// get customerGroup of the current customer (session)
$groupHandler->getGroup();
// get customerGroup code of the current customer (session)
$groupHandler->checkGroupCode();
```

### Check if a customer belongs to a group

[](#check-if-a-customer-belongs-to-a-group)

```
// check a customer
$groupHandler->checkCustomerHasGroup($myCustomer, "vip");

// check the customer currently logged-in
$groupHandler->checkGroup("vip");
```

Loops
-----

[](#loops)

### customergroup

[](#customergroup-1)

This loop list customer groups.

#### Input arguments

[](#input-arguments)

ArgumentDescription**id**Id or list of customer group ids.**is\_default**List only the default group.**code**Code or list of customer group codes.**order**Order of the results.**lang**Locale of the results.The **order** can be one of these:

- `position` (default)
- `position-reverse`
- `id`
- `id-reverse`
- `code`
- `code-reverse`
- `title`
- `title-reverse`
- `is_default`
- `is_default-reverse`

#### Output variables

[](#output-variables)

VariableDescription$CUSTOMER\_GROUP\_IDGroup id.$CODEGroup code.$TITLEGroup title in the selected locale.$DESCRIPTIONGroup description in the selected locale.$IS\_DEFAULTWhether the group is the default group or not.$POSITIONGroup position.$LOCALELocale of the results.### customercustomergroup

[](#customercustomergroup)

This group lists the associations between customers and customer groups.

#### Input arguments

[](#input-arguments-1)

ArgumentDescription**customer**Id or list of customer ids.**customer\_group**Id or list of customer group ids.#### Output variables

[](#output-variables-1)

VariableDescription$CUSTOMER\_IDId of the customer.$CUSTOMER\_GROUP\_IDId of the group the customer belongs to.### customer

[](#customer)

This module also adds group information to the customer loop and allows filtering the customers using groups.

#### Additional input arguments

[](#additional-input-arguments)

ArgumentDescription**customer\_group\_id**Id or list of customer group ids.**customer\_group\_code**Code or list of customer group codes.**customer\_group\_is\_default**List only customers in the default group.### Additional output variables

[](#additional-output-variables)

VariableDescription$CUSTOMER\_GROUP\_IDId of the customer's group.$CUSTOMER\_GROUP\_CODECode of the customer's group.$CUSTOMER\_GROUP\_DEFAULTWhether the customer's group is the default group.Query
-----

[](#query)

### CustomerQuery

[](#customerquery)

This module provides a `CustomerQuery` class that extends the base Thelia query and provides methods to filter customers by group.

It can be used in replacement of the base CustomerQuery.

```
use CustomerGroup\Model\CustomerQuery as CustomerGroupCustomerQuery;

$customers = CustomerGroupCustomerQuery::create()
    ->filterByCustomerGroup("myGroup")
    ->find();
```

Or mixed in your own query class by using the static methods. These methods take a `ModelCriteria` query class and will act on it.

They assume that the customer table is already present in the query scope, so your query must for exemple extends `CustomerQuery` or make a join to the customer table.

```
use CustomerGroup\Model\CustomerQuery as CustomerGroupCustomerQuery;

// MyQuery extends CustomerQuery
// or MyQuery has a join to the customer table somewhere
$myQuery = MyQuery::create();

CustomerGroupCustomerQuery::addCustomerGroupFilter($myQuery, "myGroup");
```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance78

Regular maintenance activity

Popularity16

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~654 days

Recently: every ~974 days

Total

7

Last Release

118d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2196919?v=4)[thelia](/maintainers/thelia)[@thelia](https://github.com/thelia)

---

Top Contributors

[![bcbrr](https://avatars.githubusercontent.com/u/4911969?v=4)](https://github.com/bcbrr "bcbrr (6 commits)")[![Soldras](https://avatars.githubusercontent.com/u/11573385?v=4)](https://github.com/Soldras "Soldras (2 commits)")[![bilhackmac](https://avatars.githubusercontent.com/u/3740078?v=4)](https://github.com/bilhackmac "bilhackmac (1 commits)")[![gmichard](https://avatars.githubusercontent.com/u/4465582?v=4)](https://github.com/gmichard "gmichard (1 commits)")

### Embed Badge

![Health badge](/badges/thelia-customer-group-module/health.svg)

```
[![Health](https://phpackages.com/badges/thelia-customer-group-module/health.svg)](https://phpackages.com/packages/thelia-customer-group-module)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
