setono-custom / sylius-pickup-point-plugin-custom
Sylius的取货点插件
Requires
- php: ^7.3
- sylius/sylius: ^1.3
- symfony/config: ^4.4 || ^5.0
- symfony/intl: ^4.4 || ^5.0
- symfony/messenger: ^4.4 || ^5.0
- thecodingmachine/safe: ^1.0
Requires (Dev)
- kalessil/production-dependencies-guard: dev-master
- kriswallsmith/buzz: ^1.1
- matthiasnoback/symfony-dependency-injection-test: ^4.1
- nyholm/psr7: ^1.3
- phpspec/phpspec: ^6.2
- phpunit/phpunit: ^8.5
- roave/security-advisories: dev-master
- setono/code-quality-pack: ^1.4.1
- setono/dao-bundle: ^1.0
- setono/gls-webservice-bundle: ^1.0.1
- setono/post-nord-bundle: ^1.1
- setono/sylius-behat-pack: ^0.1.0
- symfony/debug-bundle: ^5.1
- symfony/dotenv: ^5.1
- symfony/web-profiler-bundle: ^5.0
Suggests
- 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
Conflicts
- setono/post-nord-php-sdk: <1.1.3
- dev-master / 1.0.x-dev
- 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-local-custom
- dev-dependabot/composer/psalm/plugin-symfony-tw-2.4or-tw-3.0
- dev-add-danish-translation
This package is auto-updated.
Last update: 2024-09-29 06:20:04 UTC
README
将包含取货点的 <select>
添加到选择配送的结账步骤中。
支持的提供商
- 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
提供商在生产环境中无法工作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 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
的说明。