This plugin allows you to choose a delivery date and time.
Install the plugin with composer
:
composer require monsieurbiz/sylius-shipping-slot-plugin
If you are using Symfony Flex, the recipe will automatically do some actions.
For the installation without Flex, follow these additional steps
1. Add the plugin to your `config/bundles.php` file:
return [
// ...
MonsieurBiz\SyliusShippingSlotPlugin\MonsieurBizSyliusShippingSlotPlugin::class => ['all' => true],
];
- Import the plugin's configuration by creating a new file
config/packages/monsieurbiz_sylius_shipping_slot_plugin.yaml
with the following content:
imports:
- { resource: "@MonsieurBizSyliusShippingSlotPlugin/Resources/config/config.yaml" }
- Import the plugin's routing by creating a new file
config/routes/monsieurbiz_sylius_shipping_slot_plugin.yaml
with the following content:
monsieurbiz_sylius_shipping_slot_plugin:
resource: "@MonsieurBizSyliusShippingSlotPlugin/Resources/config/routing.yaml"
- Copy the override template from the plugin to your
templates
directory:
mkdir -p templates/bundles/; cp -Rv vendor/monsieurbiz/sylius-shipping-slot-plugin/src/Resources/views/SyliusShopBundle templates/bundles/
After that, follow the next steps:
- Your
Order
entity should implement theMonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderInterface
and use theMonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderTrait
trait:
namespace App\Entity\Order;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderInterface as MonsieurBizOrderInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_order")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_order')]
-class Order extends BaseOrder
+class Order extends BaseOrder implements MonsieurBizOrderInterface
{
+ use OrderTrait;
}
- Your
ProductVariant
entity should implement theMonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantInterface
and use theMonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantTrait
trait:
namespace App\Entity\Product;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantInterface as MonsieurBizProductVariantInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantTrait;
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product_variant")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_product_variant')]
-class ProductVariant extends BaseProductVariant
+class ProductVariant extends BaseProductVariant implements MonsieurBizProductVariantInterface
{
+ use ProductVariantTrait;
+
protected function createTranslation(): ProductVariantTranslationInterface
{
return new ProductVariantTranslation();
}
}
- Your
Shipment
entity should implement theMonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentInterface
and use theMonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentTrait
trait:
namespace App\Entity\Shipping;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentInterface as MonsieurBizShipmentInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentTrait;
use Sylius\Component\Core\Model\Shipment as BaseShipment;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_shipment")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_shipment')]
-class Shipment extends BaseShipment
+class Shipment extends BaseShipment implements MonsieurBizShipmentInterface
{
+ use ShipmentTrait;
}
- Your
ShippingMethod
entity should implement theMonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodInterface
and use theMonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodTrait
trait:
namespace App\Entity\Shipping;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodInterface as MonsieurBizShippingMethodInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodTrait;
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
use Sylius\Component\Shipping\Model\ShippingMethodTranslationInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_shipping_method")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_shipping_method')]
-class ShippingMethod extends BaseShippingMethod
+class ShippingMethod extends BaseShippingMethod implements MonsieurBizShippingMethodInterface
{
+ use ShippingMethodTrait {
+ ShippingMethodTrait::__construct as private shippingMethodTraitConstruct;
+ }
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->shippingMethodTraitConstruct();
+ }
+
protected function createTranslation(): ShippingMethodTranslationInterface
{
return new ShippingMethodTranslation();
}
}
- Update your database schema with the following command:
bin/console doctrine:migrations:migrate
- Generate the migration and update your database schema:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
- Glacier1891
- WahsWash
You can open an issue or a Pull Request if you want! 😘
Thank you!