Skip to content

Latest commit

 

History

History
175 lines (134 loc) · 5.98 KB

README.md

File metadata and controls

175 lines (134 loc) · 5.98 KB

PPL parcelshops plugin

Features

  • Enables sending shipments via PPL to PPL parcelshops.
  • The user can choose the PPL parcelshops from the map during checkout in the Shipment step.
  • See PPL parcelshop in final checkout step and also in the admin panel.
  • Export CSV with the PPL parcelshops shipments and import it easily into PPL's system.

Installation

  1. Run $ composer require mangoweb-sylius/sylius-ppl-parcelshops-plugin.

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

    return [
       ...
       MangoSylius\ShipmentExportPlugin\MangoSyliusShipmentExportPlugin::class => ['all' => true],
       MangoSylius\SyliusPplParcelshopsPlugin\MangoSyliusPplParcelshopsPlugin::class => ['all' => true],
    ];
  3. Add routing to config/_routes.yaml

    sylius_ppl_parcelshops_plugin:
        resource: '@MangoSyliusPplParcelshopsPlugin/Resources/config/routing.yml'
    
    mango_sylius_shipment_export_plugin:
        resource: '@MangoSyliusShipmentExportPlugin/Resources/config/routing.yml'
        prefix: /admin
  4. Your Entity Shipment has to implement \MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShipmentInterface. You can use the trait \MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShipmentTrait.

    <?php 
    
    declare(strict_types=1);
    
    namespace App\Entity\Shipping;
    
    use Doctrine\ORM\Mapping as ORM;
    use MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShipmentInterface;
    use MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShipmentTrait;
    use Sylius\Component\Core\Model\Shipment as BaseShipment;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_shipment")
     */
    class Shipment extends BaseShipment implements PplShipmentInterface
    {
        use PplShipmentTrait;
    }
  5. Your Entity ShippingMethod has to implement \MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShippingMethodInterface. You can use the trait \MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShippingMethodTrait.

    <?php 
    
    declare(strict_types=1);
    
    namespace App\Entity\Shipping;
    
    use Doctrine\ORM\Mapping as ORM;
    use MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShippingMethodInterface;
    use MangoSylius\SyliusPplParcelshopsPlugin\Model\PplShippingMethodTrait;
    use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_shipping_method")
     */
    class ShippingMethod extends BaseShippingMethod implements PplShippingMethodInterface
    {
        use PplShippingMethodTrait;
    }
  6. Include @MangoSyliusPplParcelshopsPlugin/Admin/ShippingMethod/_pplForm.html.twig into @SyliusAdmin/ShippingMethod/_form.html.twig.

    ...	
    {{ include('@MangoSyliusPplParcelshopsPlugin/Admin/ShippingMethod/_pplForm.html.twig') }}
  7. Include @MangoSyliusPplParcelshopsPlugin/Shop/Checkout/SelectShipping/_pplChoice.html.twig into @SyliusShop/Checkout/SelectShipping/_choice.html.twig.

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

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

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

    {% extends '@MangoSyliusShipmentExportPlugin/_row.html.twig' %}
    
    {% block address %}
       {% if row.pplKTMID %}
          {{ include('@MangoSyliusPplParcelshopsPlugin/_exporterRow.html.twig') }}
       {% else %}
          {{ parent() }}
       {% endif %}
    {% endblock %}
  11. 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 PPL parcelshop, create new shipping method in the admin panel, check To PPL ParcelShop enabled.
  • PPL CSV export will be generated for shipping method which has the code 'ppl_parcel_shop', you can change this in parameters, it is an array.
    parameters:
        pplShippingMethodsCodes: ['ppl_parcel_shop']

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.