arobases / sylius-transporter-label-generation-plugin
Arobases transporter label generation plugin for sylius
Maintainers
Details
github.com/Arobases-Sylius-Plugins/ArobasesSyliusTransporterLabelGenerationPlugin
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 4
Type:sylius-plugin
Requires
- php: ^7.4 || ^8.0
- ext-simplexml: *
- ext-soap: *
- sylius/sylius: 1.10.14
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-debug-extension: ^2.0.0
- 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
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.99
- phpstan/phpstan-doctrine: 0.12.33
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-webmozart-assert: 0.12.12
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^4.4 || ^5.2
- symfony/debug-bundle: ^4.4 || ^5.2
- symfony/dotenv: ^4.4 || ^5.2
- symfony/intl: ^4.4 || ^5.2
- symfony/web-profiler-bundle: ^4.4 || ^5.2
- vimeo/psalm: 4.7.1
- dev-main
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- dev-dependabot/composer/vimeo/psalm-5.9.0
- dev-dependabot/composer/phpstan/phpstan-doctrine-0.12.44
- dev-dependabot/composer/phpstan/phpstan-0.12.100
- dev-dependabot/composer/phpstan/phpstan-webmozart-assert-0.12.16
This package is auto-updated.
Last update: 2024-11-18 12:39:56 UTC
README
Installation
Step 1: Download the plugin
composer require arobases/sylius-transporter-label-generation-plugin
Step 2: Enable the plugin
<?php # config/bundles.php return [ Arobases\SyliusTransporterLabelGenerationPlugin\ArobasesSyliusTransporterLabelGenerationPlugin::class => ['all' => true], ];
Step 3: Import Routes
# config/routes.yaml arobases_sylius_transporter_label_generation_admin: resource: "@ArobasesSyliusTransporterLabelGenerationPlugin/Resources/config/admin_routing.yml" prefix: /admin
Step 4: Import config
# config/packages/arobases_sylius_transporter_label_generation.yaml imports: - { resource: "@ArobasesSyliusTransporterLabelGenerationPlugin/Resources/config/resources.yaml" }
Step 5: Include Traits
override Shipment entity to include TransporterTrait
# Entity/Shipping/Shipment.php /** * @ORM\Entity * @ORM\Table(name="sylius_shipment") */ class Shipment extends BaseShipment { use TransporterTrait; }
override Address entity to include PickupPointTrait
# Entity/Addressing/Address.php /** * @ORM\Entity * @ORM\Table(name="sylius_address") */ class Address extends BaseAddress { use PickupPointTrait; }
override Product entity to include HsCodeTrait and add the field to your form
# Entity/Product/Product.php /** * @ORM\Entity * @ORM\Table(name="sylius_product") */ class Product extends BaseProduct { use HsCodeTrait; }
# Form/Extension/Product/ProductTypeExtension.php ->add('hsCode', TextType::class,[ 'label' => "arobases_sylius_transporter_label_generation_plugin.form.product.hs_code", 'required' => false ])
# Product/Tab/_details.html.twig
{{ form_row(form.hsCode) }}
override OrderRepository or add it 'findByShipment'
# OrderRepository.php public function findByShipment($transporterId): QueryBuilder { $qb = $this->createQueryBuilder('o') ->leftJoin('o.shipments', 'shipment') ->leftJoin('shipment.transporter', 'transporter') ->andWhere('transporter.id = :transporterId') ->andWhere('o.shippingState IN (:shippingState)') ->andWhere('o.paymentState IN (:paymentState)') ->setParameter('transporterId', $transporterId) ->setParameter('shippingState', ["ready", "shipped", "in_preparation"]) ->setParameter('paymentState', ["paid"]) ; return $qb; }
Step 6: Update database
bin/console doctrine:migration:migrate
Don't forget to run those commands to generate your files
bin/console asset:install bin/console sylius:theme:asset:install
How it works
!!! think to allow file writting for label generation (public/upload/label/colissimo) !!!
Add a transporter
As things stand, you can add only Colissimo transporter. To add another one, override TransporterType and add more choices :
# TransporterType.php ->add('name', ChoiceType::class, [ 'label' => 'sylius.ui.name', 'choices' => [ 'Colissimo' => 'colissimo', 'another transporter' => 'another_transporter' ], ])
Create another connector service to looks like ColissimoRequest service and complete OrderLabelController.php to handle others transporters.