setono / sylius-review-plugin
向您的客户发送评价请求
Requires
- php: >=8.1
- doctrine/orm: ^2.0
- doctrine/persistence: ^2.0 || ^3.0
- ocramius/doctrine-batch-utils: ^2.4
- psr/event-dispatcher: ^1.0
- psr/log: ^1.1 || ^2.0 || ^3.0
- setono/composite-compiler-pass: ^1.1
- setono/doctrine-orm-trait: ^1.0.1
- sylius/core: ^1.0
- sylius/core-bundle: ^1.0
- sylius/mailer-bundle: ^1.8 || ^2.0
- sylius/order: ^1.0
- sylius/resource-bundle: ^1.6
- symfony/config: ^5.4 || ^6.4 || ^7.0
- symfony/console: ^5.4 || ^6.4 || ^7.0
- symfony/dependency-injection: ^5.4 || ^6.4 || ^7.0
- symfony/event-dispatcher: ^5.4 || ^6.4 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.4 || ^7.0
- symfony/workflow: ^5.4 || ^6.4 || ^7.0
- webmozart/assert: ^1.11
Requires (Dev)
- api-platform/core: ^2.7.16
- babdev/pagerfanta-bundle: ^3.8
- behat/behat: ^3.14
- doctrine/doctrine-bundle: ^2.11
- infection/infection: ^0.27.10
- jms/serializer-bundle: ^4.2
- lexik/jwt-authentication-bundle: ^2.17
- matthiasnoback/symfony-dependency-injection-test: ^4.3 || ^5.1
- phpunit/phpunit: ^9.6.17
- psalm/plugin-phpunit: ^0.18.4
- setono/code-quality-pack: ^2.7
- sylius/sylius: ~1.12.13
- symfony/debug-bundle: ^5.4 || ^6.4 || ^7.0
- symfony/dotenv: ^5.4 || ^6.4 || ^7.0
- symfony/intl: ^5.4 || ^6.4 || ^7.0
- symfony/property-info: ^5.4 || ^6.4 || ^7.0
- symfony/serializer: ^5.4 || ^6.4 || ^7.0
- symfony/web-profiler-bundle: ^5.4 || ^6.4 || ^7.0
- symfony/webpack-encore-bundle: ^1.17.2
- synolia/sylius-mail-tester-plugin: ^2.4
- willdurand/negotiation: ^3.1
This package is auto-updated.
Last update: 2024-09-13 18:01:13 UTC
README
向您的客户发送评价请求以获取您的商店评价。
当客户完成订单后,插件将创建一个评价请求。在初始延迟后(可配置),将通过电子邮件向客户发送评价请求,请他们评价您的商店。
在处理评价请求时(即尝试发送它时),插件将运行资格检查以确定评价请求是否有资格发送。您可以通过 挂钩到此过程 来决定是否发送评价请求。
安装
composer require setono/sylius-review-plugin
将插件类添加到您的 bundles.php
<?php $bundles = [ // ... Setono\SyliusReviewPlugin\SetonoSyliusReviewPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
确保您在 SyliusGridBundle
之前添加它,否则您将收到 您请求了一个不存在的参数 "setono_sylius_review.model.review_request.class".
异常。
更新您的数据库
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
运行命令
此插件中有两个命令。一个用于处理评价请求,另一个用于修剪评价请求表。
php bin/console setono:sylius-review:process php bin/console setono:sylius-review:prune
您自己决定多久运行这些命令。处理命令适合每天运行,而修剪命令可以每周或每月运行。
配置
setono_sylius_review: eligibility: # The initial delay before the first eligibility check. The string must be parseable by strtotime(). See https://php.ac.cn/strtotime initial_delay: '+1 week' # The maximum number of eligibility checks before the review request is automatically cancelled maximum_checks: 5 pruning: # Review requests older than this threshold will be pruned/removed. The string must be parseable by strtotime(). See https://php.ac.cn/strtotime threshold: '-1 month' resources: review_request: options: ~ classes: model: Setono\SyliusReviewPlugin\Model\ReviewRequest repository: Setono\SyliusReviewPlugin\Repository\ReviewRequestRepository factory: Sylius\Component\Resource\Factory\Factory
添加资格检查器
您可以通过实现 Setono\SyliusReviewPlugin\EligibilityChecker\ReviewRequestEligibilityCheckerInterface
来添加自己的资格检查器。
<?php use Setono\SyliusReviewPlugin\EligibilityChecker\EligibilityCheck; use Setono\SyliusReviewPlugin\EligibilityChecker\ReviewRequestEligibilityCheckerInterface; final class MyEligibilityChecker implements ReviewRequestEligibilityCheckerInterface { public function check(ReviewRequestInterface $reviewRequest): EligibilityCheck { if($this->getCustomer()->hasGreenEyes()) { return EligibilityCheck::ineligible('The review request is not eligible because we don't trust people with green eyes...'); } return EligibilityCheck::eligible(); } }
当您实现该接口时,您的服务将自动添加到资格检查器的列表中。但是,如果您不使用自动配置,您需要将服务标记为 setono_sylius_review.review_request_eligibility_checker
。
邮件测试插件
如果您使用 邮件测试插件,您可以直接从管理界面测试评价请求邮件。只需转到 https://your-store.com/admin/mail/tester
并在 Subjects
下拉菜单中选择 setono_sylius_review__review_request
。