3brs / sylius-zasilkovna-plugin
Zasilkovna plugin for Sylius
Installs: 576
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 8
Open Issues: 4
Type:sylius-plugin
Requires
- php: ^7.3|^8.0
- ext-json: *
- 3brs/sylius-shipment-export-plugin: 0.5.*
- sylius/sylius: 1.7.*|1.8.*|1.9.*|1.10.*
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-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
- lakion/mink-debug-extension: ^2.0.0
- phpspec/phpspec: ^7.0
- phpstan/phpstan: 0.12.88
- phpstan/phpstan-doctrine: 0.12.37
- phpstan/phpstan-symfony: ^0.12.7
- phpunit/phpunit: ^8.5
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0.0
- symfony/browser-kit: ^5.2
- symfony/debug-bundle: ^5.2
- symfony/dotenv: ^5.2
- symfony/intl: ^5.2
- symfony/web-profiler-bundle: ^5.2
Conflicts
- symfony/browser-kit: 4.1.8
- symfony/dependency-injection: 4.1.8
- symfony/dom-crawler: 4.1.8
- symfony/routing: 4.1.8
- symfony/symfony: 4.1.8
This package is auto-updated.
Last update: 2024-10-30 01:48:28 UTC
README
Zásilkovna Plugin
Features
- Enables sending shipments via [cz] [pl] [sk] [hu] [ro] to Zasilkovna branch or to the customer's address via Zasilkovna service.
- The user can choose the Zásilkovna branch from the map during checkout in the Shipment step.
- See Zásilkovna branch in final checkout step and also in the admin panel.
- Export CSV with the Zásilkovna shipments (both to Zasilkovna branch or customer's address) and import it easily into Zásilkovna's system.
Installation
-
Run
$ composer require 3brs/sylius-zasilkovna-plugin
. -
Add plugin classes to your
config/bundles.php
:return [ ... ThreeBRS\ShipmentExportPlugin\ThreeBRSSyliusShipmentExportPlugin::class => ['all' => true], ThreeBRS\SyliusZasilkovnaPlugin\ThreeBRSSyliusZasilkovnaPlugin::class => ['all' => true], ];
-
Add resource to
config/packeges/_sylius.yaml
imports: ... ... - { resource: "@ThreeBRSSyliusZasilkovnaPlugin/Resources/config/resources.yml" }
-
Add routing to
config/_routes.yaml
threebrs_sylius_shipment_export_plugin: resource: '@ThreeBRSSyliusShipmentExportPlugin/Resources/config/routing.yml' prefix: /admin
-
Your Entity
Shipment
has to implement\ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentInterface
. You can use the trait\ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentTrait
.<?php declare(strict_types=1); namespace App\Entity\Shipping; use Doctrine\ORM\Mapping as ORM; use ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentInterface; use ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentTrait; use Sylius\Component\Core\Model\Shipment as BaseShipment; /** * @ORM\Entity * @ORM\Table(name="sylius_shipment") */ class Shipment extends BaseShipment implements ZasilkovnaShipmentInterface { use ZasilkovnaShipmentTrait; }
-
Your Entity
ShippingMethod
has to implement\ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentInterface
. You can use the trait\ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentTrait
.<?php declare(strict_types=1); namespace App\Entity\Shipping; use Doctrine\ORM\Mapping as ORM; use ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShippingMethodInterface; use ThreeBRS\SyliusZasilkovnaPlugin\Model\ZasilkovnaShippingMethodTrait; use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod; /** * @ORM\Entity * @ORM\Table(name="sylius_shipping_method") */ class ShippingMethod extends BaseShippingMethod implements ZasilkovnaShippingMethodInterface { use ZasilkovnaShippingMethodTrait; }
-
Include
@ThreeBRSSyliusZasilkovnaPlugin/Admin/ShippingMethod/:zasilkovnaForm.html.twig
into@SyliusAdmin/ShippingMethod/_form.html.twig
.... {{ include('@ThreeBRSSyliusZasilkovnaPlugin/Admin/ShippingMethod/_zasilkovnaForm.html.twig') }}
-
Include
@ThreeBRSSyliusZasilkovnaPlugin/Shop/Checkout/SelectShipping/_zasilkovnaChoice.html.twig
into@SyliusShop/Checkout/SelectShipping/_choice.html.twig
.... {{ include('@ThreeBRSSyliusZasilkovnaPlugin/Shop/Checkout/SelectShipping/_zasilkovnaChoice.html.twig') }}
-
Replace
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.shippingAddress} %}
with{{ include('@ThreeBRSSyliusZasilkovnaPlugin/Shop/Common/Order/_addresses.html.twig') }}
in@SyliusShop/Common/Order/_addresses.html.twig
-
Replace
{% include '@SyliusAdmin/Common/_address.html.twig' with {'address': order.shippingAddress} %}
with{{ include('@ThreeBRSSyliusZasilkovnaPlugin/Admin/Common/Order/_addresses.html.twig') }}
in@SyliusAdmin/Order/Show/_addresses.html.twig
-
Override the template in
@ThreeBRSSyliusShipmentExportPlugin/_row.html.twig
{% extends '@!ThreeBRSSyliusShipmentExportPlugin/_row.html.twig' %} {% block address %} {% if row.zasilkovna %} {{ include('@ThreeBRSSyliusZasilkovnaPlugin/_exporterRow.html.twig') }} {% else %} {{ parent() }} {% endif %} {% endblock %}
-
Create and run doctrine database migrations.
For the guide how to use your own entity see Sylius docs - Customizing Models
Usage
- For delivery to the Zasilkovna branch, create new shipping method in the admin panel, set
Zásilkovna api key
and leaveCarrier ID
empty. - For delivery to customer's address, create new shipping method in the admin panel, set the
Carrier ID
and leave theZasilkovna API key
empty. - If you need to filter the points in the map by country, use the
Show only pickup points from specific country in the map
. If you leave this blank, all points in all supported countries will be shown. - Zásilkovna CSV export will be generated for shipping method which has the code 'zasilkovna', you can change this in parameters, it is an array (therefore can contain more codes, e.g. if you need to have different prices for different countries, you will need more shipping methods; it is okay to use always the same API key)
parameters: shippingMethodsCodes: ['zasilkovna']
You should add to this array both methods for shipping to Zasilkovna branch and also to customer's address via Zasilkovna service. - Packeta API documentation: https://docs.packetery.com/03-creating-packets/01-csv-import.html
- You can expand the list of countries by the parameter
parameters: threebrs_sylius_zasilkovna_plugin_payment_methods: ['cz', 'pl', 'sk', 'hu', 'ro']
Development
Usage
- Develop your plugin in
/src
- See
bin/
for useful commands
Testing
After your changes you must ensure that the tests are still passing.
$ composer install
$ bin/console doctrine:schema:create -e test
$ bin/behat
$ bin/phpstan.sh
$ bin/ecs.sh
License
This library is under the MIT license.