PHP code example of tilleuls / sylius-click-n-collect-plugin

1. Go to this page and download the library: Download tilleuls/sylius-click-n-collect-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tilleuls / sylius-click-n-collect-plugin example snippets


    
    
    // config/bundles.php

    return [
        // ...
        CoopTilleuls\SyliusClickNCollectPlugin\CoopTilleulsSyliusClickNCollectPlugin::class => ['all' => true],
    ];

4. Import the configuration:

    

    
    
    // src/Entity/Shipping/ShippingMethod.php
    
    namespace App\Entity\Shipping;
    
    use CoopTilleuls\SyliusClickNCollectPlugin\Entity\ClickNCollectShippingMethod;
    use CoopTilleuls\SyliusClickNCollectPlugin\Entity\ClickNCollectShippingMethodInterface;
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_shipping_method")
     */
    class ShippingMethod extends BaseShippingMethod implements ClickNCollectShippingMethodInterface
    {
        use ClickNCollectShippingMethod {
            __construct as initializeShippingMethodLocations;
        }
    
        public function __construct()
        {
            parent::__construct();
    
            $this->initializeShippingMethodLocations();
        }
    
        // ...
    }
    

    
    
    // src/Entity/Shipping/Shipment.php
    
    namespace App\Entity\Shipping;
    
    use CoopTilleuls\SyliusClickNCollectPlugin\Entity\ClickNCollectShipment;
    use CoopTilleuls\SyliusClickNCollectPlugin\Entity\ClickNCollectShipmentInterface;
    use CoopTilleuls\SyliusClickNCollectPlugin\Validator\Constraints\SlotAvailable;
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\Shipment as BaseShipment;
    
    /**
    * @ORM\Entity
    * @ORM\Table(name="sylius_shipment", indexes={@ORM\Index(columns={"location_id", "collection_time"})})
    * @SlotAvailable(groups={"sylius"})
    */
    class Shipment extends BaseShipment implements ClickNCollectShipmentInterface
    {
       use ClickNCollectShipment;
    }