https://github.com/cleverage/cleveragesyliuscolissimoplugin
https://github.com/cleverage/cleveragesyliuscolissimoplugin
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cleverage/cleveragesyliuscolissimoplugin
- Owner: cleverage
- License: mit
- Created: 2022-07-26T09:30:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-28T14:34:09.000Z (over 3 years ago)
- Last Synced: 2025-03-28T13:37:22.163Z (12 months ago)
- Language: PHP
- Size: 107 KB
- Stars: 5
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CleverAge/SyliusColissimoPlugin
[![Latest Version][ico-version]](https://packagist.org/packages/cleverage/sylius-colissimo-plugin)
[![Software License][ico-license]](LICENSE)
## Introduction
This sylius plugin allows you to manage parcel shipments with colissimo.
You can define delivery methods such as `colissimo pickup points` or `colissimo home delivery`.
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:
```bash
$ composer require cleverage/sylius-colissimo-plugin
```
This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.
Add bundle to your `config/bundles.php`:
```php
['all' => true],
// ...
];
```
### Step 2: Import routing and configs
#### Import routing
````yaml
# config/routes/clerverage_sylius_colissimo.yaml
clever_age_sylius_colissimo_shop:
resource: "@CleverAgeSyliusColissimoPlugin/Resources/config/shop_routing.yml"
clever_age_sylius_colissimo_admin:
resource: "@CleverAgeSyliusColissimoPlugin/Resources/config/admin_routing.yml"
prefix: /admin
````
#### Import application config
````yaml
# config/packages/_sylius.yaml
imports:
- { resource: "@CleverAgeSyliusColissimoPlugin/Resources/config/config.yaml" }
````
### Step 3: Update templates
#### Admin section
Add the following to the admin template `SyliusAdminBundle/ShippingMethod/_form.html.twig`
```twig
{{ 'clever_age.admin.ui.shipping_method.title'|trans }}
{{ form_row(form.colissimoPickup) }}
{{ form_row(form.colissimoHomeDelivery) }}
```
See an example [here](tests/Application/templates/bundles/SyliusAdminBundle/ShippingMethod/_form.html.twig).
Next add the following to the admin template `SyliusAdminBundle/Order/Show/_shipment.html.twig`
after shipment header:
```twig
{% include "CleverAgeSyliusColissimoPlugin/Shipment/Label/pickupPoint.html.twig" %}
```
See an example [here](tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/_shipment.html.twig).
#### Shop section
Add the following to the shop template `SyliusShopBundle/Checkout/SelectShipping/_choice.html.twig`
```twig
// ...
{% if method.isColissimoPickup %}
{% include '@CleverAgeSyliusColissimoPlugin/Shipment/selectedPickupPoint.html.twig' %}
{% endif %}
// ...
{% if method.isColissimoPickup %}
{% include '@CleverAgeSyliusColissimoPlugin/Shipment/map.html.twig' with {
'pickupPoints': [myPickupPoints]
} %}
{% endif %}
```
See an example [here](tests/Application/templates/bundles/SyliusShopBundle/Checkout/SelectShipping/_choice.html.twig).
Next add the following to the shop template `SyliusShopBundle/Common/Order/_shipments.html.twig`
after shipment method header:
```twig
{% include "@CleverAgeSyliusColissimoPlugin/Shipment/Label/pickupPoint.html.twig" %}
```
See an example [here](tests/Application/templates/bundles/SyliusShopBundle/Common/Order/_shipments.html.twig).
## Step 4 : Update styles, scripts and install assets
Add the following to the shop template `SyliusShopBundle/_styles.html.twig`
```twig
{% include '@SyliusUi/_stylesheets.html.twig' with { 'path': 'bundles/cleveragesyliuscolissimoplugin/css/map.css' } %}
{% include '@SyliusUi/_stylesheets.html.twig' with { 'path': 'bundles/cleveragesyliuscolissimoplugin/css/popup.css' } %}
{# Important for the map ! #}
```
See an example [here](tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig).
Next the following to the shop template `SyliusShopBundle/_scripts.html.twig`
```twig
{% include '@SyliusUi/_javascripts.html.twig' with { 'path': 'bundles/cleveragesyliuscolissimoplugin/js/select-pickup-point.js' } %}
{% include '@SyliusUi/_javascripts.html.twig' with { 'path': 'bundles/cleveragesyliuscolissimoplugin/js/change-pickup-point.js' } %}
{% include '@SyliusUi/_javascripts.html.twig' with { 'path': 'bundles/cleveragesyliuscolissimoplugin/js/select-shipping.js' } %}
```
See an example [here](tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig).
### Install assets
```bash
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