juicesweb / sylius-dpd-plugin
Simple DPD REST Plugin for Sylius
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 2
Type:sylius-plugin
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- ext-simplexml: *
- sylius/sylius: ~1.8.0 || ~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- friendsofsymfony/oauth-server-bundle: ^1.6 || >2.0.0-alpha.0 ^2.0@dev
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.99
- phpstan/phpstan-doctrine: 0.12.33
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-webmozart-assert: 0.12.12
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^4.4 || ^5.2
- symfony/debug-bundle: ^4.4 || ^5.2
- symfony/dotenv: ^4.4 || ^5.2
- symfony/intl: ^4.4 || ^5.2
- symfony/web-profiler-bundle: ^4.4 || ^5.2
- vimeo/psalm: 4.7.1
This package is not auto-updated.
Last update: 2024-12-22 15:47:58 UTC
README
Introduction
This sylius plugin allows you to manage parcel shipments with DPD.
You can define DPD pickup points
delivery method.
For pickup point deliveries, an interactive map with the list of pickup points is generated according to the delivery address entered the tunnel by the user.
Usage
TODO add screenshots
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 cleverage/sylius-dpd-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 [ // ... CleverAge\SyliusDpdPlugin\CleverAgeSyliusDpdPlugin::class => ['all' => true], // ... ];
Step 2: Import routing and configs
Import routing
# config/routes/clerverage_sylius_dpd.yaml clever_age_sylius_dpd_shop: resource: "@CleverAgeSyliusDpdPlugin/Resources/config/shop_routing.yml"
Import application config
# config/packages/_sylius.yaml imports: - { resource: "@CleverAgeSyliusDpdPlugin/Resources/config/config.yaml" }
Step 3: Update templates
Admin section
Add the following to the admin template SyliusAdminBundle/Order/Show/_shipment.html.twig
after shipment header:
{% include "CleverAgeSyliusDpdPlugin/Shipment/Label/pickupPoint.html.twig" %}
See an example here.
Shop section
Add the following to the shop template SyliusShopBundle/Checkout/SelectShipping/_choice.html.twig
// ... {% if method.isDpdPickup %} {% include '@CleverAgeSyliusDpdPlugin/Shipment/selectedPickupPoint.html.twig' %} {% endif %} // ... {% if method.isDpdPickup %} {% include '@CleverAgeSyliusDpdPlugin/Shipment/map.html.twig' with { 'pickupPoints': [myPickupPoints] } %} {% endif %}
See an example here.
Next add the following to the shop template SyliusShopBundle/Common/Order/_shipments.html.twig
after shipment method header:
{% include "@CleverAgeSyliusDpdPlugin/Shipment/Label/pickupPoint.html.twig" %}
See an example here.
Step 4 : Update styles, scripts and install assets
Add the following to the shop template SyliusShopBundle/_styles.html.twig
{% include '@SyliusUi/_stylesheets.html.twig' with { 'path': 'bundles/cleveragesyliusdpdplugin/css/dpd-map.css' } %} {% include '@SyliusUi/_stylesheets.html.twig' with { 'path': 'bundles/cleveragesyliusdpdplugin/css/dpd-popup.css' } %} {# Important for the map ! #} <link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css" integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ==" crossorigin="" />
See an example here.
Next the following to the shop template SyliusShopBundle/_scripts.html.twig
<script src="{{ asset('bundles/cleveragesyliusdpsplugin/js/dpd-map.js') }}" type="module"></script> {% include '@SyliusUi/_javascripts.html.twig' with { 'path': 'bundles/cleveragesyliusdpdplugin/js/dpd-select-shipping.js' } %} {% include '@SyliusUi/_javascripts.html.twig' with { 'path': 'bundles/cleveragesyliusdpdplugin/js/dpd-select-pickup-point.js' } %} {% include '@SyliusUi/_javascripts.html.twig' with { 'path': 'bundles/cleveragesyliusdpdplugin/js/dpd-change-pickup-point.js' } %}
See an example here.
Install assets
bin/console assets:install --symlink
Step 5 : Customize resources
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 CleverAge\SyliusDpdPlugin\Contract\DpdShippingMethodInterface; use CleverAge\SyliusDpdPlugin\Entity\Traits\DpdShippingMethodTrait; use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod; /** * @ORM\Entity() * @ORM\Table(name="sylius_shipping_method") */ class ShippingMethod extends BaseShippingMethod implements DpdShippingMethodInterface { use DpdShippingMethodTrait; }
Order resource
If you haven't extended the order resource yet, here is what it should look like :
<?php // src/Entity/Order.php declare(strict_types=1); namespace App\Entity; use CleverAge\SyliusDpdPlugin\Entity\Traits\DpdOrderTrait; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Order as BaseOrder; /** * @ORM\Entity() * @ORM\Table(name="sylius_order") */ class Order extends BaseOrder { use DpdOrderTrait; }
You can read about extending resources here.
Update shipping and order resources config
Next you need to tell Sylius that you will use your own extended resources :
# config/packages/_sylius.yaml sylius_shipping: resources: shipping_method: classes: model: App\Entity\ShippingMethod sylius_order: resources: order: classes: model: App\Entity\Order
Step 6 : Update database schema
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
Step 7 : Configure plugin
// config/packages/cleverage_sylius_dpd.yaml clever_age_sylius_dpd: securityKey: 'security key'
Enjoy now !