Skip to content

[WIP] A Sylius plugin which allow you to choose a delivery date and time

License

Notifications You must be signed in to change notification settings

delyriand/SyliusShippingSlotPlugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner of Sylius Shipping Slot plugin

Shipping Slot

Shipping Slot Plugin license Tests Security Flex Recipe

This plugin allows you to choose a delivery date and time.

Installation

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],
];
  1. 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" }
  1. 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"
  1. 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:

  1. Your Order entity should implement the MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderInterface and use the MonsieurBiz\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;
}
  1. Your ProductVariant entity should implement the MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantInterface and use the MonsieurBiz\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();
    }
}
  1. Your Shipment entity should implement the MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentInterface and use the MonsieurBiz\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;
}
  1. Your ShippingMethod entity should implement the MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodInterface and use the MonsieurBiz\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();
    }
}
  1. Update your database schema with the following command:
bin/console doctrine:migrations:migrate
  1. Generate the migration and update your database schema:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate

Sponsors

  • Glacier1891
  • WahsWash

Contributing

You can open an issue or a Pull Request if you want! 😘
Thank you!

About

[WIP] A Sylius plugin which allow you to choose a delivery date and time

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 76.1%
  • JavaScript 10.5%
  • Twig 8.4%
  • Makefile 4.8%
  • SCSS 0.2%