承接 setono/sylius-abandoned-cart-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

setono/sylius-abandoned-cart-plugin

Composer 安装命令:

composer require setono/sylius-abandoned-cart-plugin

包简介

Reengage customers who abandoned their cart in Sylius

README 文档

README

Latest Stable Version Total Downloads License PHP Version Require build codecov Mutation testing badge

Recover lost sales on autopilot. This plugin spots shopping carts your customers leave behind, then emails them a friendly reminder with a one-click link back to their cart — and a compliant unsubscribe link. Everything is tracked in the admin panel so you can see exactly which carts were notified, recovered, or opted out.

Features

  • 🛒 Automatic idle-cart detection — finds carts that have been sitting untouched for a configurable amount of time.
  • ✉️ Re-engagement emails — a clean, localized email with a recovery call-to-action and an unsubscribe link.
  • 🔁 One-click cart recovery — the recovery link restores the customer's cart and records the click for engagement tracking.
  • 🚫 Built-in opt-out & eligibility rules — never email customers who unsubscribed, and optionally target newsletter subscribers only.
  • 📊 Admin overview — a grid under Marketing → Abandoned cart listing every notification with its state, channel, customer and revenue.
  • 🧩 Extensible by design — add your own eligibility rules, tweak the idle-cart query, or override the email template.
  • 🌍 15 locales out of the boxen, da, de, es, fi, fr, hu, it, nl, no, pl, pt, ro, sv, uk.

How it works

The plugin runs as a small pipeline, driven by two commands you schedule on a cron:

  1. Detectcreate-notifications finds carts that have been idle for idle_threshold minutes and creates a Notification for each (initial state: pending).
  2. Processprocess-notifications runs every pending notification through the eligibility checks, sends the email, and transitions it to sent (or ineligible if a check fails).
  3. Recover — the email contains a recovery link (restores the cart and tracks the click) and an unsubscribe link (records the opt-out so the customer is never emailed again).

Each notification moves through a state machine:

pending ──► processing ──► sent
                       └──► ineligible
(any state) ──► failed

Requirements

Package Version
PHP 8.2+
Sylius ^2.0
Symfony 6.4 or 7.4

Using Sylius 1.x? This branch (3.x) targets Sylius 2. For Sylius 1.x support, use the 2.x branch.

Installation

1. Require the plugin

composer require setono/sylius-abandoned-cart-plugin

2. Register the bundle

Add the plugin to config/bundles.php before SyliusGridBundle — otherwise you'll get a non-existent parameter "setono_sylius_abandoned_cart.model.notification.class" error, because the grid configuration references parameters the plugin registers.

<?php
// config/bundles.php

return [
    // ...
    Setono\SyliusAbandonedCartPlugin\SetonoSyliusAbandonedCartPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    // ...
];

3. Import the routes

# config/routes/setono_sylius_abandoned_cart.yaml
setono_sylius_abandoned_cart:
    resource: "@SetonoSyliusAbandonedCartPlugin/config/routes.yaml"

This registers the admin grid routes (under /admin/abandoned-cart) and the shop routes for cart recovery and unsubscribe.

4. Configure the salt

The unsubscribe links are signed with a SHA-256 hash. Set a secret salt and change it in production — anyone who knows it could forge unsubscribe links.

# config/packages/setono_sylius_abandoned_cart.yaml
setono_sylius_abandoned_cart:
    salt: '%env(ABANDONED_CART_SALT)%' # or any secret string

5. Install assets

bin/console assets:install

6. Update your database schema

bin/console doctrine:migrations:diff    # generate a migration
bin/console doctrine:migrations:migrate # apply it

7. Schedule the commands

The plugin needs create-notifications and process-notifications to run regularly. A typical crontab:

# Detect newly-idle carts (run more often than `lookback_window`, e.g. every 5 minutes)
*/5 * * * * cd /path/to/your/app && bin/console setono:sylius-abandoned-cart:create-notifications

# Send emails for pending notifications
*/5 * * * * cd /path/to/your/app && bin/console setono:sylius-abandoned-cart:process-notifications

# Clean up old notifications once a day
0 3 * * *   cd /path/to/your/app && bin/console setono:sylius-abandoned-cart:prune-notifications

Commands

Command What it does
setono:sylius-abandoned-cart:create-notifications Finds idle carts and creates notifications. Supports --dry-run to preview.
setono:sylius-abandoned-cart:process-notifications Runs eligibility checks and sends the emails.
setono:sylius-abandoned-cart:prune-notifications Deletes notifications older than prune_older_than.

Preview which carts would be picked up, without persisting anything:

bin/console setono:sylius-abandoned-cart:create-notifications --dry-run

Configuration reference

# config/packages/setono_sylius_abandoned_cart.yaml
setono_sylius_abandoned_cart:
    # Secret salt used to sign unsubscribe URLs (SHA-256). Required — change it in production.
    salt: '%env(ABANDONED_CART_SALT)%'

    # Minutes a cart must be idle before it's eligible for a notification (default: 60)
    idle_threshold: 60

    # Only carts that became idle within this many minutes are picked up, which caps how many
    # notifications are created per run. Run create-notifications more often than this. (default: 15)
    lookback_window: 15

    # Prune notifications older than this many minutes (default: 43200 = 30 days)
    prune_older_than: 43200

    eligibility_checkers:
        # Skip customers who actively unsubscribed (default: true)
        unsubscribed_customer: true

        # Only notify customers subscribed to the newsletter (default: false)
        subscribed_to_newsletter: false

Customization

Add a custom eligibility rule

Implement NotificationEligibilityCheckerInterface and return an EligibilityCheck. With Symfony autoconfiguration enabled (the default), the plugin discovers and registers your checker automatically — no service config needed.

<?php

declare(strict_types=1);

namespace App\EligibilityChecker;

use Setono\SyliusAbandonedCartPlugin\EligibilityChecker\EligibilityCheck;
use Setono\SyliusAbandonedCartPlugin\EligibilityChecker\NotificationEligibilityCheckerInterface;
use Setono\SyliusAbandonedCartPlugin\Model\NotificationInterface;

final class MinimumCartTotalEligibilityChecker implements NotificationEligibilityCheckerInterface
{
    public function check(NotificationInterface $notification): EligibilityCheck
    {
        $cart = $notification->getCart();

        if (null === $cart || $cart->getTotal() < 5000) {
            // The reason is stored on the notification for debugging.
            return new EligibilityCheck(false, 'Cart total is below the minimum');
        }

        return new EligibilityCheck(true);
    }
}

If you've disabled autoconfiguration, tag the service manually with setono_sylius_abandoned_cart.notification_eligibility_checker.

Customize which carts are considered "idle"

The idle-cart query is dispatched as a QueryBuilderForIdleCartsCreated event before it runs, so you can add your own constraints. The cart root alias is o:

<?php

declare(strict_types=1);

namespace App\EventListener;

use Setono\SyliusAbandonedCartPlugin\Event\QueryBuilderForIdleCartsCreated;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener]
final class OnlyNotifyMainChannelListener
{
    public function __invoke(QueryBuilderForIdleCartsCreated $event): void
    {
        $event->queryBuilder
            ->andWhere('o.channel = :channel')
            ->setParameter('channel', 1);
    }
}

Override the email template

Copy the template into your app and edit it — Symfony's template overriding does the rest:

templates/bundles/SetonoSyliusAbandonedCartPlugin/email/notification.html.twig

Override translations

Override any string by redefining its key (under the setono_sylius_abandoned_cart.* prefix) in your app's translations/messages.<locale>.yml.

Contributing

composer install

composer phpunit       # run the test suite
composer analyse       # PHPStan (max level)
composer check-style   # coding standards (ECS)
composer fix-style     # auto-fix coding standards

A full Sylius test application lives in tests/Application for functional tests and manual testing. See CLAUDE.md for architecture notes and developer conventions.

License

This plugin is released under the MIT License.

setono/sylius-abandoned-cart-plugin 适用场景与选型建议

setono/sylius-abandoned-cart-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.06k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「sylius」 「sylius-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 setono/sylius-abandoned-cart-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 setono/sylius-abandoned-cart-plugin 我们能提供哪些服务?
定制开发 / 二次开发

基于 setono/sylius-abandoned-cart-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 23.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-30