asdoria / sylius-shipping-delivery-time-plugin
Add shipping delivery time for products.
Installs: 503
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 0
Forks: 1
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^8.0
- sylius/sylius: ^1.12
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
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.37
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sylius-labs/coding-standard: ^4.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: 5.9.0
README
Installation
Require plugin with composer:
$ composer require asdoria/sylius-shipping-delivery-time-plugin
Import configuration:
# config/packages/asdoria_shipping_delivery_time.yaml imports: - { resource: "@AsdoriaSyliusShippingDeliveryTimePlugin/Resources/config/app/config.yaml" } # Uncomment next line if you're using Webpack Encore # - { resource: "@AsdoriaSyliusShippingDeliveryTimePlugin/Resources/config/app/config_webpack.yaml" }
Import routing:
# config/routes/asdoria_shipping_delivery_time.yaml asdoria_sylius_shipping_delivery_time: resource: "@AsdoriaSyliusShippingDeliveryTimePlugin/Resources/config/routes.yaml"
or if your app doesn't use locales:
# config/routes.yaml asdoria_sylius_shipping_delivery_time: resource: "@AsdoriaSyliusShippingDeliveryTimePlugin/Resources/config/routes_no_locale.yaml"
Override ShippingMethod Entity
Make App\Entity\Shipping\ShippingMethod
extend ShippingMethodCountdownAwareInterface
use Asdoria\SyliusShippingDeliveryTimePlugin\Traits\Aware\ShippingMethodCountdownAwareTrait; use Asdoria\SyliusShippingDeliveryTimePlugin\Model\Aware\ShippingMethodCountdownAwareInterface; /** * Class ShippingMethod * * @author Philippe Vesin <pve.asdoria@gmail.com> */ class ShippingMethod extends BaseShippingMethod implements ShippingMethodCountdownAwareInterface { use ShippingMethodCountdownAwareTrait; /** * ShippingMethod constructor. */ public function __construct() { parent::__construct(); $this->initializeShippingSchedulesCollection(); } }
If you don't use annotations, make src/Resources/config/doctrine/Shipping/ShippingMethod.orm.xml
<mapped-superclass name="App\Entity\Shipping\ShippingMethod" table="sylius_shipping_method"> <field name="deliveryWeekdays" column="delivery_weekdays" nullable="true" type="array"/> <field name="deliveryMaxTime" column="delivery_max_time" nullable="true" type="integer"> <options> <option name="default">0</option> </options> </field> <field name="deliveryMinTime" column="delivery_min_time" nullable="true" type="integer"> <options> <option name="default">0</option> </options> </field> <one-to-many target-entity="Asdoria\SyliusShippingDeliveryTimePlugin\Model\ShippingScheduleInterface" mapped-by="shippingMethod" field="shippingSchedules" orphan-removal="true" > <cascade> <cascade-all/> </cascade> </one-to-many> <field name="additionalDeliveryTime" column="additional_delivery_time" nullable="true" type="json" /> </mapped-superclass>
Override Product Entity
Make App\Entity\Product\Product
extend ProductCountdownAwareInterface
use Asdoria\SyliusShippingDeliveryTimePlugin\Model\Aware\ProductCountdownAwareInterface; use Asdoria\SyliusShippingDeliveryTimePlugin\Traits\Aware\ProductCountdownAwareTrait; /** * Class Product * @package App\Entity\Product * * @author Philippe Vesin <pve.asdoria@gmail.com> */ class Product extends BaseProduct implements ProductInterface, ProductCountdownAwareInterface { use ProductCountdownAwareTrait; }
If you don't use annotations, make src/Resources/config/doctrine/Product/Product.orm.xml
<mapped-superclass name="App\Entity\Product\Product" table="sylius_product"> <field name="additionalDeliveryTime" column="additional_delivery_time" nullable="true" type="integer"> <options> <option name="default">0</option> </options> </field> </mapped-superclass>
Override Channel Entity
Make App\Entity\Channel\Channel
extend DefaultShippingZoneAwareInterface
use Asdoria\SyliusShippingDeliveryTimePlugin\Model\Aware\DefaultShippingZoneAwareInterface; use Asdoria\SyliusShippingDeliveryTimePlugin\Traits\Aware\DefaultShippingZoneAwareTrait; class Channel extends BaseChannel implements ChannelInterface, DefaultShippingZoneAwareInterface { use DefaultShippingZoneAwareTrait; }
If you don't use annotations, make src/Resources/config/doctrine/Channel/Channel.orm.xml
<mapped-superclass name="App\Entity\Channel\Channel" table="sylius_channel"> <many-to-one field="defaultShippingZone" target-entity="Sylius\Component\Addressing\Model\ZoneInterface"/> </mapped-superclass>
Add plugin class to your bundles.php
:
<?php $bundles = [ // ... Asdoria\SyliusShippingDeliveryTimePlugin\AsdoriaSyliusShippingDeliveryTimePlugin::class => ['all' => true], // ... ];
- Copy the template overrides from the plugin directory
From: [shop_dir] vendor/asdoria/sylius-shipping-delivery-time-plugin/Resources/views/bundles/SyliusAdminBundle/*
To: [shop_dir] templates/bundles/SyliusAdminBundle/*
Update your database:
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
Install assets:
php bin/console assets:install
Clear cache:
php bin/console cache:clear