Skip to content

JakobTolkemit/SyliusCustomOptionsPlugin

This branch is 15 commits behind Brille24/SyliusCustomOptionsPlugin:master.

Folders and files

NameName
Last commit message
Last commit date
Nov 1, 2022
Aug 4, 2021
Jan 15, 2022
Oct 30, 2022
Nov 1, 2022
Mar 15, 2023
Nov 2, 2022
Aug 4, 2021
Oct 30, 2018
Oct 22, 2021
Oct 10, 2019
Mar 16, 2020
Oct 14, 2020
Feb 28, 2020
Aug 4, 2021
Mar 1, 2023
Oct 22, 2022
Oct 30, 2022
Feb 28, 2020
Aug 4, 2021
Aug 4, 2021
Nov 2, 2022

Repository files navigation

Customer Options

With this plugin the customer can add additional info to the product like so: Price import forms Price import forms

Installation

  • Run composer require brille24/sylius-customer-options-plugin.

  • Register the Plugin in your config/bundles.php:

return [
    //...
    Brille24\SyliusCustomerOptionsPlugin\Brille24SyliusCustomerOptionsPlugin::class => ['all' => true],
];
  • Add the config.yml to your local config/packages/_sylius.yaml:
imports:
    ...
    - { resource: "@Brille24SyliusCustomerOptionsPlugin/Resources/config/app/config.yml" }
  • Add the routing.yml to your local config/routes.yaml:
brille24_customer_options:
    resource: "@Brille24SyliusCustomerOptionsPlugin/Resources/config/app/routing.yml"
  • Copy the template overrides from the plugin directory
From: [shop_dir]/vendor/brille24/sylius-customer-options-plugin/test/Application/templates
To: [shop_dir]/templates

In order to use the customer options, you need to override the product and order item.

use Brille24\SyliusCustomerOptionsPlugin\Entity\ProductInterface;
use Brille24\SyliusCustomerOptionsPlugin\Traits\ProductCustomerOptionCapableTrait;
use Sylius\Component\Core\Model\Product as BaseProduct;

class Product extends BaseProduct implements ProductInterface {
    use ProductCustomerOptionCapableTrait {
        __construct as protected customerOptionCapableConstructor;
    }
    
     public function __construct()
    {
        parent::__construct();

        $this->customerOptionCapableConstructor();
    }
    // ...
}
use Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItemInterface;
use Brille24\SyliusCustomerOptionsPlugin\Traits\OrderItemCustomerOptionCapableTrait;
use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;

class OrderItem extends BaseOrderItem implements OrderItemInterface
{
    use OrderItemCustomerOptionCapableTrait {
        __construct as protected customerOptionCapableConstructor;
    }

    public function __construct()
    {
        parent::__construct();

        $this->customerOptionCapableConstructor();
    }
    // ...
}
  • If you also want default data you need to copy over the brille24_sylius_customer_options_plugin_fixtures.yaml file from the package directory and run
bin/console sylius:fixtures:load
  • Finally, update the database and update the translations:
bin/console doctrine:migrations:migrate
bin/console translation:update

Things to consider

  • Saving files as customer defined values as the values are currently stored as a string in the database

Developing

When developing it is recommended to use git hooks for this just copy the docs/pre-commit to .git/hooks/pre-commit and make it executable. Then you will check your codestyle before committing.

Usage

Documentation on how to use the plugin can be found here.

About

A Sylius plugin that adds customer options

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 86.8%
  • Twig 6.4%
  • Gherkin 6.0%
  • JavaScript 0.8%