webgriffe / sylius-table-rate-shipping-plugin
Provides table rate shipping calculator.
Installs: 84 783
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 4
Forks: 10
Open Issues: 4
Type:sylius-plugin
pkg:composer/webgriffe/sylius-table-rate-shipping-plugin
Requires
- php: ^8.2
 - sylius/sylius: ^2.0
 
Requires (Dev)
- behat/behat: ^3.16
 - behat/mink-selenium2-driver: ^1.6
 - dbrekelmans/bdi: ^1.4
 - dmore/behat-chrome-extension: ^1.4
 - dmore/chrome-mink-driver: ^2.9
 - friends-of-behat/mink: ^1.11
 - friends-of-behat/mink-browserkit-driver: ^1.6
 - friends-of-behat/mink-debug-extension: ^2.1
 - friends-of-behat/mink-extension: ^2.7
 - friends-of-behat/page-object-extension: ^0.3
 - friends-of-behat/suite-settings-extension: ^1.1
 - friends-of-behat/symfony-extension: ^2.6
 - friends-of-behat/variadic-extension: ^1.6
 - phpspec/phpspec: ^8.0
 - phpstan/extension-installer: ^1.0
 - phpstan/phpstan: ^1.12
 - phpstan/phpstan-doctrine: ^1.3
 - phpstan/phpstan-strict-rules: ^1.3.0
 - phpstan/phpstan-webmozart-assert: ^1.2
 - phpunit/phpunit: ^10.5
 - polishsymfonycommunity/symfony-mocker-container: ^1.0
 - psalm/plugin-symfony: ^5.2
 - robertfausk/behat-panther-extension: ^1.1
 - sylius-labs/coding-standard: ^4.4
 - sylius-labs/suite-tags-extension: ~0.2
 - sylius/sylius-rector: ^2.0
 - sylius/test-application: ^2.0.0@alpha
 - symfony/browser-kit: ^6.4 || ^7.1
 - symfony/debug-bundle: ^6.4 || ^7.1
 - symfony/dotenv: ^6.4 || ^7.1
 - symfony/http-client: ^6.4 || ^7.1
 - symfony/intl: ^6.4 || ^7.1
 - symfony/runtime: ^6.4 || ^7.1
 - symfony/web-profiler-bundle: ^6.4 || ^7.1
 - symfony/webpack-encore-bundle: ^2.2
 - vimeo/psalm: ^6.13
 
README
Table Rate Shipping Plugin
This plugin allows to define shipping rates using weight tables.
Installation
- 
Run
composer require --no-scripts webgriffe/sylius-table-rate-shipping-plugin. - 
Add the plugin to the
config/bundles.phpfile:Webgriffe\SyliusTableRateShippingPlugin\WebgriffeSyliusTableRateShippingPlugin::class => ['all' => true],
 - 
Add the plugin's config to by creating the file
config/packages/webgriffe_sylius_table_rate_shipping_plugin.yamlwith the following content:imports: - { resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/config.yml" }
 - 
Add the plugin's routing by creating the file
config/routes/webgriffe_sylius_table_rate_shipping_plugin.yamlwith the following content:webgriffe_sylius_table_rate_shipping_plugin_shop: resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/shop_routing.yml" prefix: /{_locale} requirements: _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ webgriffe_sylius_table_rate_shipping_plugin_admin: resource: "@WebgriffeSyliusTableRateShippingPlugin/Resources/config/admin_routing.yml" prefix: /%sylius_admin.path_name%
 - 
Finish the installation by updating the database schema and installing assets:
bin/console cache:clear bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate bin/console assets:install bin/console sylius:theme:assets:install
 
Contributing
To contribute you need to:
- 
Clone this repository into you development environment and go to the plugin's root directory,
 - 
Then, from the plugin's root directory, run the following commands:
composer install
 - 
Copy
tests/Application/.envintests/Application/.env.localand set configuration specific for your development environment. - 
Then, from the plugin's root directory, run the following commands:
(cd tests/Application && yarn install) (cd tests/Application && yarn build) (cd tests/Application && bin/console assets:install public) (cd tests/Application && bin/console doctrine:database:create) (cd tests/Application && bin/console doctrine:schema:create) (cd tests/Application && bin/console sylius:fixtures:load) (cd tests/Application && symfony server:start -d) # Requires Symfony CLI (https://symfony.com/download)
 - 
Now at http://localhost:8080/ you have a full Sylius testing application which runs the plugin
 
Testing
After your changes you must ensure that the tests are still passing.
First setup your test database:
```bash
(cd tests/Application && bin/console -e test doctrine:database:create)
(cd tests/Application && bin/console -e test doctrine:schema:create)
```
This plugin's test application already comes with a test configuration that uses SQLite as test database.
If you don't want this you can create a tests/Application/.env.test.local with a different DATABASE_URL.
The current CI suite runs the following tests:
- 
Easy Coding Standard
vendor/bin/ecs check src/ tests/Behat/
 - 
PHPStan
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
 - 
PHPUnit
vendor/bin/phpunit
 - 
PHPSpec
vendor/bin/phpspec run
 - 
Behat (without Javascript)
vendor/bin/behat --tags="~@javascript" - 
Behat (only Javascript)
vendor/bin/behat --tags="@javascript" 
To run them all with a single command run:
composer suite
To run Behat's Javascript scenarios you need to setup Selenium and Chromedriver. Do the following:
- 
Start Headless Chrome:
google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1
 - 
Install SSL certificates (only once needed) and run test application's webserver on
127.0.0.1:8080:symfony server:ca:install APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon
 
License
This library is under the MIT license. See the complete license in the LICENSE file.
Credits
Developed by Webgriffe®.