PHPackages                             breadhead/mailchimp-ecommerce-event-pusher - 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. [API Development](/categories/api)
4. /
5. breadhead/mailchimp-ecommerce-event-pusher

ActiveLibrary[API Development](/categories/api)

breadhead/mailchimp-ecommerce-event-pusher
==========================================

MailChimp Ecommerce Event Pusher

3.0.0(6y ago)0464proprietaryPHPPHP &gt;=7.2

Since Mar 2Pushed 6y ago2 watchersCompare

[ Source](https://github.com/breadhead/mailchimp-ecommerce-event-pusher)[ Packagist](https://packagist.org/packages/breadhead/mailchimp-ecommerce-event-pusher)[ Docs](https://github.com/breadhead/bh-yii2-mailchimp-ecommerce-event-pusher.git)[ RSS](/packages/breadhead-mailchimp-ecommerce-event-pusher/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (0)

mailchimp-event-pusher
======================

[](#mailchimp-event-pusher)

Send events to mailchimp ecommerce

do migrations:

php yii migrate --migrationPath=@vendor/breadhead/yii2-mailchimp-ecommerce-event-pusher/src/migrations/

Implement your model class from MailchimpEventInterface. This ecommerce module for tracking:

- Cart
- Order
- Customer and Contact
- Product

Example of realization:

```
public function saveMailchimpEvent(string $event_type): MailchimpEvent
    {
        $event = (new MailchimpEvent())->setEntityId($this->id)->setEntityType(MailchimpEvent::CUSTOMER)->setEventType($event_type)->setData($this->getMailchimpData())->save();

        return $event;
    }

public function getMailchimpData()
{
    return [
        'id' => (string)$this->id,
        "email_address" =>(string)$this->email,
        'opt_in_status' => (bool)$this->subscribe,
        'first_name' => (string)$this->name,
        'last_name' => (string)$this->last_name,
        'orders_count' => count($this->orders),
        'total_spent' => (float)OrderModel::find()->where(['status' => OrderModel::PAYED, 'customer_id' => $this->id])->sum('total')
    ];
}

```

config:

```
'components' => [
    'mailchimpeventpusher' => function () {
        $storeId = ;
        $mailchimpApiKey = ;
        $listId = ;

        $client = new \breadhead\mailchimp\api\MailchimpClient($mailchimpApiKey);
        $sender = new \breadhead\mailchimp\MailchimpEventSender($client, $storeId, $listId);

        return new \breadhead\mailchimp\MailchimpEventPusher($storeId, $sender);
    }
]

```

To send events code example:

```
class MailchimpController extends Controller
{
    private $maxEventsPerStep;

    ...

    public function actionSendevents(): void
    {
        $jobs = $this->defineJobs();

        $this->doJobs($jobs);
    }

    private function doJobs($jobs): bool
    {
        try {
            $eventSender = \Yii::$app->mailchimpeventpusher->getManager();

            foreach ($jobs as $event) {
                $event->status = MailchimpEventModel::RUN;
                Helper::saveAndLogModel($event);

                $mailchimpEvent = MailchimpEvent::create($event->id);

                /* @var MailchimpEventSender $eventSender */
                $eventSender->sendEvent($mailchimpEvent);
            }
        } catch (\Exception $e) {

            throw $e;
        }

        return true;
    }

    private function defineJobs(): array
    {
        if (MailchimpEventModel::findOne(['status' => MailchimpEventModel::RUN])) {
            return [];
        }

        return MailchimpEventModel::find()
            ->where(['status' => MailchimpEventModel::NEW])
            ->orderBy(['created_at' => 'ASC'])
            ->limit($this->maxEventsPerStep)
            ->all();
    }
    ...
}

```

Important issue that if you need to unsubscribe your customer or delete it, customer methods don't help in this case. You need to use Member as an EntityType. Check example below (from CustomerModel ActiveRecord class) for more details:

```
public function supportEvent(string $eventType): bool
{
    $support = YII_ENV == 'prod';

    if ($support && $eventType == ActiveRecord::EVENT_BEFORE_UPDATE && $this->subscribe  $this->oldAttributes['subscribe']) {
        $support = true;
    }

    return $support;
}

public function createAndSaveMailchimpEvent(string $eventType): MailchimpEvent
{
    if ($this->user->status == BaseActiveRecord::DELETED && $eventType == ActiveRecord::EVENT_AFTER_UPDATE) {
        $event = MailchimpEvent::createEmpty()
            ->setEntityId(MC_PREFIX . $this->id)
            ->setEntityType(MailchimpEvent::CONCACT)
            ->setEventType(ActiveRecord::EVENT_AFTER_DELETE)
            ->setData($this->getMailchimpMemberData())
            ->save();
    } elseif ($eventType == ActiveRecord::EVENT_BEFORE_UPDATE) {
        $event = MailchimpEvent::createEmpty()
            ->setEntityId(MC_PREFIX . $this->id)
            ->setEntityType(MailchimpEvent::CONCACT)
            ->setEventType(ActiveRecord::EVENT_AFTER_UPDATE)
            ->setData($this->getMailchimpMemberData())
            ->save();
    } else {
        $event = MailchimpEvent::createEmpty()
            ->setEntityId(MC_PREFIX . $this->id)
            ->setEntityType(MailchimpEvent::CUSTOMER)
            ->setEventType($eventType)
            ->setData($this->getMailchimpData())
            ->save();
    }

    return $event;
}

public function getMailchimpData()
{
    return [
        'id'            => (string) MC_PREFIX . $this->id,
        'email_address' => (string) $this->email,
        'opt_in_status' => (bool) $this->subscribe,
        'first_name'    => (string) $this->name,
        'orders_count'  => count($this->orders),
        'total_spent'   => (float) OrderModel::find()
            ->where(['transaction.status' => OrderModel::PAYED, 'order.customer_id' => $this->id])
            ->joinWith('transaction')
            ->sum('transaction.total')
    ];
}

public function getMailchimpMemberData()
{
    return [
        'email_address' => $this->user->status == self::DELETED ? $this->name: $this->email,
        'status' => $this->subscribe ? 'subscribed' : 'unsubscribed'
    ];
}

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~72 days

Recently: every ~54 days

Total

11

Last Release

2269d ago

Major Versions

0.2 → 1.0.02018-10-10

1.4.0 → 2.0.02019-07-27

2.5.0 → 3.0.02020-02-28

PHP version history (2 changes)0.1PHP &gt;=5.3.19

1.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca3b1e67a954346dcb1ef5d4768a9150198a9fd6992439361aa9730ba2839150?d=identicon)[waytonoway](/maintainers/waytonoway)

---

Top Contributors

[![waytonoway](https://avatars.githubusercontent.com/u/16236916?v=4)](https://github.com/waytonoway "waytonoway (9 commits)")

---

Tags

phpapiyii2ecommercemailchimp

### Embed Badge

![Health badge](/badges/breadhead-mailchimp-ecommerce-event-pusher/health.svg)

```
[![Health](https://phpackages.com/badges/breadhead-mailchimp-ecommerce-event-pusher/health.svg)](https://phpackages.com/packages/breadhead-mailchimp-ecommerce-event-pusher)
```

###  Alternatives

[pacely/mailchimp-apiv3

Simple API wrapper for Mailchimp API V3

95654.6k2](/packages/pacely-mailchimp-apiv3)[robwittman/shopify-php-sdk

PHP SDK for Shopify API

7098.9k1](/packages/robwittman-shopify-php-sdk)[vatps/mailchimp-rest-api

Very Easy to use MailChimp REST Enabled API 3.0 Wrapper Class.

2877.3k](/packages/vatps-mailchimp-rest-api)[robby-bugatti/shopify-php-sdk

PHP SDK for Shopify API

702.7k](/packages/robby-bugatti-shopify-php-sdk)

PHPackages © 2026

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