setono-custom/sylius-pickup-point-plugin-local 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

setono-custom/sylius-pickup-point-plugin-local

Composer 安装命令:

composer require setono-custom/sylius-pickup-point-plugin-local

包简介

Pickup point plugin for Sylius

README 文档

README

Latest Version Latest Unstable Version Software License Build Status

Add a <select> that contains pickup points to your select shipping checkout step.

List of pickup points

Supported providers

  • DAO
  • GLS
  • PostNord
  • Fake provider (for development/playing purposes)

Screenshots

Shop

This is the shipping method step in the checkout process where you can choose a pickup point.

Screenshot showing checkout select shipping step with pickup points available

On the complete order step in checkout you can see the pickup point you have chosen.

Screenshot showing checkout complete step with pickup point address

Admin

On the order you can see what pickup point the customer has chosen.

Screenshot showing admin order shipping page with pickup point address

When you edit shipping method you can associate a pickup point provider to that shipping method.

Screenshot showing admin shipping method with some pickup point providers

Installation

Step 1: Install and enable plugin

Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:

$ composer require setono/sylius-pickup-point-plugin

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Add bundle to your config/bundles.php:

<?php
# config/bundles.php

return [
    // ...
    Setono\SyliusPickupPointPlugin\SetonoSyliusPickupPointPlugin::class => ['all' => true],
    // ...
];

Step 2: Import routing and configs

Import routing

# config/routes/setono_sylius_pickup_point.yaml
setono_sylius_pickup_point_plugin:
    resource: "@SetonoSyliusPickupPointPlugin/Resources/config/routing.yaml"

Import application config

# config/packages/setono_sylius_pickup_point.yaml
imports:
    - { resource: "@SetonoSyliusPickupPointPlugin/Resources/config/app/config.yaml" }    

(Optional) Import fixtures to play in your app

# config/packages/setono_sylius_pickup_point.yaml
imports:
    - { resource: "@SetonoSyliusPickupPointPlugin/Resources/config/app/fixtures.yaml" }    

Step 3: Update templates

Add the following to the admin template SyliusAdminBundle/ShippingMethod/_form.html.twig

{{ form_row(form.pickupPointProvider) }}

See an example here.

Next add the following to the shop template SyliusShopBundle/Checkout/SelectShipping/_shipment.html.twig

{% form_theme form.pickupPointId '@SetonoSyliusPickupPointPlugin/Form/theme.html.twig' %}

{{ form_row(form.pickupPointId) }}

See an example here.

Next add the following to the shop template SyliusShopBundle/Common/Order/_shipments.html.twig after shipment method header:

{% include "@SetonoSyliusPickupPointPlugin/Shop/Label/Shipment/pickupPoint.html.twig" %}

See an example here.

Next add the following to the admin template SyliusAdminBundle/Order/Show/_shipment.html.twig after shipment header:

{% include "@SetonoSyliusPickupPointPlugin/Shop/Label/Shipment/pickupPoint.html.twig" %}

See an example here.

Step 4: Customize resources

Shipment resource

If you haven't extended the shipment resource yet, here is what it should look like:

<?php
// src/Entity/Shipment.php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusPickupPointPlugin\Model\PickupPointAwareTrait;
use Setono\SyliusPickupPointPlugin\Model\ShipmentInterface;
use Sylius\Component\Core\Model\Shipment as BaseShipment;

/**
 * @ORM\Entity()
 * @ORM\Table(name="sylius_shipment")
 */
class Shipment extends BaseShipment implements ShipmentInterface
{
    use PickupPointAwareTrait;
}

Shipping method resource

If you haven't extended the shipping method resource yet, here is what it should look like:

<?php
// src/Entity/ShippingMethod.php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusPickupPointPlugin\Model\PickupPointProviderAwareTrait;
use Setono\SyliusPickupPointPlugin\Model\ShippingMethodInterface;
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;

/**
 * @ORM\Entity()
 * @ORM\Table(name="sylius_shipping_method")
 */
class ShippingMethod extends BaseShippingMethod implements ShippingMethodInterface
{
    use PickupPointProviderAwareTrait;
}

You can read about extending resources here.

Update shipping resources config

Next you need to tell Sylius that you will use your own extended resources:

# config/packages/_sylius.yaml

sylius_shipping:
    resources:
        shipment:
            classes:
                model: App\Entity\Shipment
        shipping_method:
            classes:
                model: App\Entity\ShippingMethod

Step 5: Configure plugin

Enable desired providers

Note that:

  • faker provider will not work on prod environment
  • gls provider require setono/gls-webservice-bundle to be installed
  • dao provider require setono/dao-bundle to be installed
  • post_nord provider require setono/post-nord-bundle to be installed
# config/packages/setono_sylius_pickup_point.yaml
setono_sylius_pickup_point:
    providers:
        faker: true
        gls: true
        post_nord: true
        dao: true

If you want to use cache

Cache disabled by default. To enable it, make next configuration:

# config/packages/setono_sylius_pickup_point.yaml
framework:
    cache:
        pools:
            setono_sylius_pickup_point.provider_cache_pool:
                adapter: cache.app

setono_sylius_pickup_point:
    cache:
        enabled: true
        pool: setono_sylius_pickup_point.provider_cache_pool

Step 6: Update database schema

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

Step 7: Update validation groups

Add checkout_select_shipping to sylius.form.type.checkout_select_shipping.validation_groups:

# config/packages/_sylius.yaml

parameters:
    sylius.form.type.checkout_select_shipping.validation_groups: ['sylius', 'checkout_select_shipping']

Step 8: Install assets

bin/console sylius:install:assets  
bin/console sylius:theme:assets:install

Play

To see pickup points list, use next example address at checkout:

Dannebrogsgade 1
9000 Aalborg
DK
Hämeentie 1
00350 Helsinki
FI
Vasterhaninge 1
137 94 Stockholm
SE

Note, that providers have their pickup points only at given countries:

So, to play with all 3 providers at once - use DK address.

Troubleshooting

  • At /en_US/checkout/select-shipping step you see No results found at Pickup point id field.

    • Check your browser's developer console and make sure JS scripts loaded correctly. Also make sure setono-pickup-point.js compiled (read as you not forgot to run sylius:install:assets).

    • Make sure content of plugin's src/Resources/views/_javascripts.html.twig actually rendered. If not - probably, you erased {{ sonata_block_render_event('sylius.shop.layout.javascripts') }} from your custom layout.html.twig.

    Also, make sure {{ sonata_block_render_event('sylius.admin.layout.javascripts') }} in place at your admin's layout.html.twig if it was customized.

    • If you're using themes, make sure you executed sylius:theme:assets:install after plugin installation.
  • The service "setono_sylius_pickup_point.registry.provider" has a dependency on a non-existent service "setono_post_nord.http_client".

    You should specify setono_post_nord.http_client configuration or define Buzz\Client\BuzzClientInterface service to use as default http client. See Setono/PostNordBundle#1

    You should add config/packages/buzz.yaml and config/packages/nyholm_psr7.yaml configs.

  • You're facing Pickup point cannot be blank. validation error at /checkout/address step at your application

    Make sure you're followed instructions from Installation step 7.

setono-custom/sylius-pickup-point-plugin-local 适用场景与选型建议

setono-custom/sylius-pickup-point-plugin-local 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 setono-custom/sylius-pickup-point-plugin-local 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-31