setono / sylius-pickup-point-plugin
Pickup point plugin for Sylius
Fund package maintenance!
Setono
Installs: 50 437
Dependents: 7
Suggesters: 0
Security: 0
Stars: 18
Watchers: 2
Forks: 19
Open Issues: 11
Type:sylius-plugin
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-11-14 10:28:04 UTC
README
Add a <select>
that contains pickup points to your select shipping checkout step.
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.
On the complete order step in checkout you can see the pickup point you have chosen.
Admin
On the order you can see what pickup point the customer has chosen.
When you edit shipping method you can associate a pickup point provider to that shipping method.
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 environmentbudbee
provider requiresetono/budbee-bundle
to be installedcoolrunner
provider requiresetono/coolrunner-bundle
to be installedgls
provider requiresetono/gls-webservice-bundle
to be installeddao
provider requiresetono/dao-bundle
to be installedpost_nord
provider requiresetono/post-nord-bundle
to be installed
# 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
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:
- DAO: DK
- PostNord: DK, SE, FI
- GLS: See https://gls-group.eu/EU/en/depot-parcelshop-search
So, to play with all 3 providers at once - use DK
address.
Troubleshooting
-
At
/en_US/checkout/select-shipping
step you seeNo results found
atPickup 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 runsylius: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 customlayout.html.twig
.
Also, make sure
{{ sonata_block_render_event('sylius.admin.layout.javascripts') }}
in place at your admin'slayout.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 defineBuzz\Client\BuzzClientInterface
service to use as default http client. See Setono/PostNordBundle#1You 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 applicationMake sure you're followed instructions from
Installation step 7
.