定制 setono/sylius-review-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

setono/sylius-review-plugin

最新稳定版本:v1.0.0-beta

Composer 安装命令:

composer require setono/sylius-review-plugin

包简介

Send review requests to your customers

README 文档

README

Latest Version Software License Build Status Code Coverage Mutation testing

Send review requests to your customers to receive reviews for your store.

The plugin will create a review request upon customers completing an order. After an initial delay (configurable), a review request will be sent as an email to the customer asking them to review your store.

When processing a review request (i.e. trying to send it), the plugin will run an eligibility check to see if the review request is eligible to be sent. You can hook into this process to decide whether a review request should be sent or not.

Installation

composer require setono/sylius-review-plugin

Add plugin class to your bundles.php:

<?php
$bundles = [
    // ...
    Setono\SyliusReviewPlugin\SetonoSyliusReviewPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    // ...
];

Make sure you add it before SyliusGridBundle, otherwise you'll get You have requested a non-existent parameter "setono_sylius_review.model.review_request.class". exception.

Update your database

php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

Run commands

There are two commands in this plugin. One for processing review requests and one for pruning the review request table.

php bin/console setono:sylius-review:process
php bin/console setono:sylius-review:prune

You decide yourself how often you want to run these commands. The process command makes sense to run daily, while the prune command can be run weekly or monthly.

Configuration

setono_sylius_review:
    eligibility:
        # The initial delay before the first eligibility check. The string must be parseable by strtotime(). See https://www.php.net/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://www.php.net/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

Add eligibility checker

You can add your own eligibility checker by implementing the 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();
    }
}

When you implement the interface, your service will automatically be added to the list of eligibility checkers. However, if you don't use autoconfiguration, you need to tag your service with setono_sylius_review.review_request_eligibility_checker.

Mail tester plugin

If you use the mail tester plugin you can test the review request email directly from the admin interface. Just go to https://your-store.com/admin/mail/tester and select the setono_sylius_review__review_request in the Subjects dropdown.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-15