Skip to content
Zásilkovna / Zásielkovňa / Csomagküldő / Przesyłkownia / Coletăria
PHP Gherkin HTML JavaScript Shell
Branch: master
Clone or download
Latest commit bf932c3 Dec 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin initial commit Dec 13, 2019
doc initial commit Dec 13, 2019
features
src
tests initial commit Dec 13, 2019
.editorconfig initial commit Dec 13, 2019
.gitignore
.travis.yml initial commit Dec 13, 2019
README.md initial commit Dec 13, 2019
behat.yml.dist initial commit Dec 13, 2019
composer.json initial commit Dec 13, 2019
easy-coding-standard.yml
logo.png initial commit Dec 13, 2019
node_modules initial commit Dec 13, 2019
phpstan.neon
phpunit.xml.dist initial commit Dec 13, 2019

README.md

Zásilkovna Plugin

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

Features

  • Adds shipment type Zásilkovna [cz] [pl] [sk] [hu] [ro] branch which allows sending ordered products to selected Zásilkovna branch.
  • The user can choose the Zásilkovna branch during checkout in the Shipment step.
  • Zásilkovna branches are displayed according to the zone of the shipment.
  • See Zásilkovna branch in final checkout step and also in the admin panel.
  • Export CSV with the Zásilkovna shipments and import it easily into Zásilkovna's system.

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_zasilkovna_plugin:
        resource: '@MangoSyliusZasilkovnaPlugin/Resources/config/routing.yml'
        prefix: /admin
    
    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/Checkout/SelectShipping:_zasilkovnaChoice.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/Common/Order/_addresses.html.twig

  11. Override the template in MangoSyliusShipmentExportPlugin::_row.html.twig

    {% extends 'MangoSyliusShipmentExportPlugin::_row.html.twig' %}
    
    {% block address %}
    {% if row.zasilkovna %}
    	{{ 'mangoweb.admin.zasilkovna.export.toZasilkovnaBranch'|trans }}: {{ row.zasilkovna }}
    {% else %}
    	{{ 'mangoweb.admin.zasilkovna.export.toAddress'|trans }}:
    	{% if row.order.shippingAddress.company %}
    		{{ row.order.shippingAddress.company }},
    	{% endif %}
    	{{ row.order.shippingAddress.firstName }}
    	{{ row.order.shippingAddress.lastName }},
    	{{ row.order.shippingAddress.street }},
    	{{ row.order.shippingAddress.postcode }}
    	{{ row.order.shippingAddress.city }},
    	{{ row.order.shippingAddress.countryCode }}
    {% endif %}
    {% endblock %}
  12. Create and run doctrine database migrations.

For the guide how to use your own entity see Sylius docs - Customizing Models

Usage

  • Create new shipping method in the admin panel and set Zásilkovna api key, save it and click Sync Zásilkovna branches button to load the list of branches into the current database.

  • 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 need to select the appripriate countries for the zone where Zásilkovna has some branches

  • Zásilkovna branches are updated on their servers daily between 0:00 - 1:00 CET. Just call this command (via cron) once a day, ideally during the night after 1:00. Details here: https://www.zasilkovna.cz/eshopy/implementace/xml

    mango:zasilkovna:sync

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.

You can’t perform that action at this time.