setono / sylius-pickup-point-plugin
Sylius的取货点插件
Requires
- php: >=8.1
- ext-mbstring: *
- behat/transliterator: ^1.5
- doctrine/event-manager: ^1.2
- doctrine/orm: ^2.7
- friendsofsymfony/rest-bundle: ^2.8 || ^3.0
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/http-client: ^1.0
- sylius/core: ^1.0
- sylius/core-bundle: ^1.0
- sylius/order: ^1.0
- sylius/registry: ^1.0
- sylius/resource-bundle: ^1.8
- sylius/shipping: ^1.0
- sylius/shipping-bundle: ^1.0
- symfony/cache: ^5.4 || ^6.0
- symfony/config: ^5.4 || ^6.0
- symfony/console: ^5.4 || ^6.0
- symfony/dependency-injection: ^5.4 || ^6.0
- symfony/form: ^5.4 || ^6.0
- symfony/http-foundation: ^5.4 || ^6.0
- symfony/http-kernel: ^5.4 || ^6.0
- symfony/intl: ^5.4 || ^6.0
- symfony/messenger: ^5.4 || ^6.0
- symfony/options-resolver: ^5.4 || ^6.0
- symfony/routing: ^5.4 || ^6.0
- symfony/security-bundle: ^5.4 || ^6.0
- symfony/validator: ^5.4 || ^6.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
- fakerphp/faker: ^1.21
- jms/serializer-bundle: ^4.2
- kriswallsmith/buzz: ^1.2
- lexik/jwt-authentication-bundle: ^2.17
- matthiasnoback/symfony-config-test: ^4.3 || ^5.1
- matthiasnoback/symfony-dependency-injection-test: ^4.3 || ^5.1
- nyholm/psr7: ^1.5
- phpspec/phpspec: ^7.3
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.6.17
- polishsymfonycommunity/symfony-mocker-container: ^1.0.7
- psalm/plugin-phpunit: ^0.18.4
- psalm/plugin-symfony: ^5.0
- setono/budbee-bundle: ^1.0
- setono/code-quality-pack: ^2.7
- setono/coolrunner-bundle: ^1.0
- setono/dao-bundle: ^1.1
- setono/gls-webservice-bundle: ^1.3
- setono/post-nord-bundle: ^2.0@alpha
- setono/post-nord-php-sdk: ^2.0@alpha
- setono/sylius-behat-pack: ^0.2
- sylius/sylius: ~1.12.13
- symfony/debug-bundle: ^5.4 || ^6.4
- symfony/dotenv: ^5.4 || ^6.4
- symfony/property-info: ^5.4 || ^6.4
- symfony/serializer: ^5.4 || ^6.4
- symfony/web-profiler-bundle: ^5.4 || ^6.4
- symfony/webpack-encore-bundle: ^1.17.2
- weirdan/doctrine-psalm-plugin: ^2.8
- willdurand/negotiation: ^3.1
Suggests
- setono/coolrunner-bundle: Install this bundle to use the CoolRunner provider
- setono/dao-bundle: Install this bundle to use the DAO provider
- setono/gls-webservice-bundle: Install this bundle to use the GLS provider
- setono/post-nord-bundle: Install this bundle to use the PostNord provider
- 2.x-dev
- 1.x-dev
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-beta.13
- v1.0.0-beta.12
- v1.0.0-beta.11
- v1.0.0-beta.10
- v1.0.0-beta.9
- v1.0.0-beta.8
- v1.0.0-beta.7
- v1.0.0-beta.6
- v1.0.0-beta.5
- v1.0.0-beta.4
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- v1.0.0-beta
- dev-remove-cached-provider
- dev-remove-local-pickup-points
This package is auto-updated.
Last update: 2024-09-14 10:04:26 UTC
README
将包含取货点的
支持的服务提供商
- DAO
- GLS
- PostNord
- 假服务提供商(用于开发和娱乐目的)
截图
商店
这是结账过程中的送货方式步骤,您可以在此选择取货点。
在结账的完成订单步骤中,您可以查看您选择的取货点。
管理员
在订单中,您可以看到客户选择的取货点。
当您编辑送货方式时,可以将取货点提供商与该送货方式相关联。
安装
步骤 1:安装并启用插件
打开命令行,进入您的项目目录,并执行以下命令以下载此插件的最新稳定版本
$ composer require setono/sylius-pickup-point-plugin
此命令要求您已全局安装Composer,请参阅Composer文档中的安装章节。
将包添加到您的 config/bundles.php
<?php # config/bundles.php return [ // ... Setono\SyliusPickupPointPlugin\SetonoSyliusPickupPointPlugin::class => ['all' => true], // ... ];
步骤 2:导入路由和配置
导入路由
# config/routes/setono_sylius_pickup_point.yaml setono_sylius_pickup_point_plugin: resource: "@SetonoSyliusPickupPointPlugin/Resources/config/routing.yaml"
导入应用程序配置
# config/packages/setono_sylius_pickup_point.yaml imports: - { resource: "@SetonoSyliusPickupPointPlugin/Resources/config/app/config.yaml" }
(可选) 将固定数据导入您的应用程序
# config/packages/setono_sylius_pickup_point.yaml imports: - { resource: "@SetonoSyliusPickupPointPlugin/Resources/config/app/fixtures.yaml" }
步骤 3:更新模板
将以下内容添加到管理员模板 SyliusAdminBundle/ShippingMethod/_form.html.twig
{{ form_row(form.pickupPointProvider) }}
示例请参阅这里。
然后添加以下内容到商店模板 SyliusShopBundle/Checkout/SelectShipping/_shipment.html.twig
{% form_theme form.pickupPointId '@SetonoSyliusPickupPointPlugin/Form/theme.html.twig' %} {{ form_row(form.pickupPointId) }}
示例请参阅这里。
然后添加以下内容到商店模板 SyliusShopBundle/Common/Order/_shipments.html.twig
在送货方式标题之后
{% include "@SetonoSyliusPickupPointPlugin/Shop/Label/Shipment/pickupPoint.html.twig" %}
示例请参阅这里。
然后添加以下内容到管理员模板 SyliusAdminBundle/Order/Show/_shipment.html.twig
在送货方式标题之后
{% include "@SetonoSyliusPickupPointPlugin/Shop/Label/Shipment/pickupPoint.html.twig" %}
示例请参阅这里。
步骤 4:自定义资源
送货资源
如果您尚未扩展送货资源,以下是它的样子
<?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; }
送货方式资源
如果您尚未扩展送货方式资源,以下是它的样子
<?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; }
有关扩展资源的更多信息,请参阅这里。
更新送货资源配置
接下来,您需要告诉Sylius您将使用您自己的扩展资源
# config/packages/_sylius.yaml sylius_shipping: resources: shipment: classes: model: App\Entity\Shipment shipping_method: classes: model: App\Entity\ShippingMethod
步骤 5:配置插件
启用所需的服务提供商
注意:
faker
服务提供商在生产环境中无法工作budbee
服务提供商需要安装setono/budbee-bundle
coolrunner
服务提供商需要安装setono/coolrunner-bundle
gls
服务提供商需要安装setono/gls-webservice-bundle
dao
服务提供商需要安装setono/dao-bundle
post_nord
服务提供商需要安装setono/post-nord-bundle
# config/packages/setono_sylius_pickup_point.yaml setono_sylius_pickup_point: providers: faker: true budbee: true coolrunner: true gls: true post_nord: true dao: true
如果您想使用缓存
默认禁用缓存。要启用它,请进行以下配置
# 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
步骤 6:更新数据库模式
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
步骤 7:更新验证组
将 checkout_select_shipping
添加到 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']
步骤 8:安装资源
bin/console sylius:install:assets bin/console sylius:theme:assets:install
运行
要查看取货点列表,请在结账时使用以下示例地址
Dannebrogsgade 1
9000 Aalborg
DK
Hämeentie 1
00350 Helsinki
FI
Vasterhaninge 1
137 94 Stockholm
SE
请注意,提供商只在特定的国家设有取货点
- DAO:DK
- PostNord:DK,SE,FI
- GLS:请参阅 https://gls-group.eu/EU/en/depot-parcelshop-search
因此,要同时使用所有 3 个提供商,请使用 DK
地址。
故障排除
-
在
/en_US/checkout/select-shipping
步骤中,您在取货点 ID
字段看到没有找到结果
。-
检查您的浏览器开发控制台,并确保 JS 脚本正确加载。同时,请确保
setono-pickup-point.js
已编译(阅读时请确保您没有忘记运行sylius:install:assets
)。 -
确保插件
src/Resources/views/_javascripts.html.twig
的内容实际上已渲染。如果没有,则可能是因为您从自定义的layout.html.twig
中删除了{{ sonata_block_render_event('sylius.shop.layout.javascripts') }}
。
此外,如果您已自定义,请确保在管理员
layout.html.twig
中放置了{{ sonata_block_render_event('sylius.admin.layout.javascripts') }}
。- 如果您使用主题,请确保在插件安装后执行了
sylius:theme:assets:install
。
-
-
服务 "setono_sylius_pickup_point.registry.provider" 依赖于一个不存在的服务 "setono_post_nord.http_client"。
您应该指定
setono_post_nord.http_client
配置或定义Buzz\Client\BuzzClientInterface
服务作为默认的 HTTP 客户端。请参阅 Setono/PostNordBundle#1您应该添加 config/packages/buzz.yaml 和 config/packages/nyholm_psr7.yaml 配置。
-
您在应用程序的
/checkout/address
步骤遇到取货点不能为空。
验证错误确保您已遵循
安装步骤 7
的说明。