mangoweb-sylius/sylius-zasilkovna-plugin

This package is abandoned and no longer maintained. The author suggests using the 3brs/sylius-zasilkovna-plugin package instead.

Zasilkovna plugin for Sylius


README

38423357?s=200&v=4

Zásilkovna Plugin
68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616e676f7765622d73796c6975732f73796c6975732d7a6173696c6b6f766e612d706c7567696e2e737667 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616e676f7765622d73796c6975732f73796c6975732d7a6173696c6b6f766e612d706c7567696e2e737667 68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616e676f7765622d73796c6975732f53796c6975735a6173696c6b6f766e61506c7567696e2f6d61737465722e737667

Zásilkovna / Zásielkovňa / Csomagküldő / Przesyłkownia / Coletăria

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.

admin_order_detail.png

admin_shipping_method_edit.png

shop_shipment_step.png

shop_checkout_complete.png

Installation

  1. Run $ composer require mangoweb-sylius/sylius-zasilkovna-plugin.

  2. Add plugin classes to your config/bundles.php:

    return [
       ...
       MangoSylius\ShipmentExportPlugin\MangoSyliusShipmentExportPlugin::class => ['all' => true],
       MangoSylius\SyliusZasilkovnaPlugin\MangoSyliusZasilkovnaPlugin::class => ['all' => true],
    ];
  3. Add resource to config/packeges/_sylius.yaml

    imports:
         ...
         ...
         - { resource: "@MangoSyliusZasilkovnaPlugin/Resources/config/resources.yml" }
  4. Add routing to config/_routes.yaml

    mango_sylius_shipment_export_plugin:
        resource: '@MangoSyliusShipmentExportPlugin/Resources/config/routing.yml'
        prefix: /admin
  5. Your Entity Shipment has to implement \MangoSylius\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentInterface. You can use the trait \MangoSylius\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentTrait.

    <?php 
    
    declare(strict_types=1);
    
    namespace App\Entity\Shipping;
    
    use Doctrine\ORM\Mapping as ORM;
    use MangoSylius\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentInterface;
    use MangoSylius\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;
    }
  6. Your Entity ShippingMethod has to implement \MangoSylius\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentInterface. You can use the trait \MangoSylius\SyliusZasilkovnaPlugin\Model\ZasilkovnaShipmentTrait.

    <?php 
    
    declare(strict_types=1);
    
    namespace App\Entity\Shipping;
    
    use Doctrine\ORM\Mapping as ORM;
    use MangoSylius\SyliusZasilkovnaPlugin\Model\ZasilkovnaShippingMethodInterface;
    use MangoSylius\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;
    }
  7. Include @MangoSyliusZasilkovnaPlugin/Admin/ShippingMethod/:zasilkovnaForm.html.twig into @SyliusAdmin/ShippingMethod/_form.html.twig.

    ...	
    {{ include('@MangoSyliusZasilkovnaPlugin/Admin/ShippingMethod/_zasilkovnaForm.html.twig') }}
  8. Include @MangoSyliusZasilkovnaPlugin/Shop/Checkout/SelectShipping/_zasilkovnaChoice.html.twig into @SyliusShop/Checkout/SelectShipping/_choice.html.twig.

    ...
    {{ include('@MangoSyliusZasilkovnaPlugin/Shop/Checkout/SelectShipping/_zasilkovnaChoice.html.twig') }}
  9. Replace {% include '@SyliusShop/Common/_address.html.twig' with {'address': order.shippingAddress} %} with {{ include('@MangoSyliusZasilkovnaPlugin/Shop/Common/Order/_addresses.html.twig') }} in @SyliusShop/Common/Order/_addresses.html.twig

  10. Replace {% include '@SyliusAdmin/Common/_address.html.twig' with {'address': order.shippingAddress} %} with {{ include('@MangoSyliusZasilkovnaPlugin/Admin/Common/Order/_addresses.html.twig') }} in @SyliusAdmin/Order/Show/_addresses.html.twig

  11. Override the template in @MangoSyliusShipmentExportPlugin/_row.html.twig

    {% extends '@!MangoSyliusShipmentExportPlugin/_row.html.twig' %}
    
    {% block address %}
       {% if row.zasilkovna %}
            {{ include('@MangoSyliusZasilkovnaPlugin/_exporterRow.html.twig') }}
       {% else %}
           {{ parent() }}
       {% endif %}
    {% endblock %}
  12. 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 leave Carrier ID empty.
  • For delivery to customer's address, create new shipping method in the admin panel, set the Carrier ID and leave the Zasilkovna 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

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.

Credits

Developed by manGoweb.