webgriffe / sylius-table-rate-shipping-plugin
Provides table rate shipping calculator.
Installs: 70 877
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 6
Forks: 10
Open Issues: 3
Type:sylius-plugin
Requires
- php: ^8.1
- sylius/sylius: ^1.13.3
- symfony/webpack-encore-bundle: ^1.15
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.6
- dbrekelmans/bdi: ^1.1
- 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
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.16
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.6 || ^10.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.2
- sylius-labs/suite-tags-extension: ^0.2
- symfony/browser-kit: ^5.4 || ^6.0
- symfony/debug-bundle: ^5.4 || ^6.0
- symfony/dotenv: ^5.4 || ^6.0
- symfony/flex: ^2.2.2
- symfony/intl: ^5.4 || ^6.0
- symfony/web-profiler-bundle: ^5.4 || ^6.0
- vimeo/psalm: 4.27.0
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.php
file:Webgriffe\SyliusTableRateShippingPlugin\WebgriffeSyliusTableRateShippingPlugin::class => ['all' => true],
-
Add the plugin's config to by creating the file
config/packages/webgriffe_sylius_table_rate_shipping_plugin.yaml
with 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.yaml
with 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/.env
intests/Application/.env.local
and 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®.