brille24 / sylius-customer-options-plugin
Adds product customizing to Sylius
Installs: 24 673
Dependents: 1
Suggesters: 0
Security: 0
Stars: 41
Watchers: 9
Forks: 27
Open Issues: 10
Type:sylius-plugin
Requires
- php: ^7.4 || ^8.0
- sylius/sylius: ~1.9.0 || ~1.10.0 || ~1.11.0
- symfony/event-dispatcher: ^4.3 || ^5.0
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
- friendsofsymfony/oauth-server-bundle: >2.0.0-alpha.0 ^2.0@dev
- mamazu/documentation-validator: dev-master
- phpspec/phpspec: ^7.0
- phpstan/phpstan: ^0.12.85
- phpstan/phpstan-doctrine: ^0.12.33
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-symfony: ^0.10|^0.12
- phpstan/phpstan-webmozart-assert: ^0.12.12
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^4.4 || ^5.4
- symfony/debug-bundle: ^4.4 || ^5.4
- symfony/dotenv: ^4.4 || ^5.4
- symfony/intl: ^4.4 || ^5.4
- symfony/web-profiler-bundle: ^4.4 || ^5.4
- vimeo/psalm: 4.7.1
Conflicts
- doctrine/dbal: ^3.0
- dev-master
- v2.16.1
- v2.16.0
- 2.15.0
- 2.14.2
- 2.14.1
- 2.14.0
- 2.13.1
- 2.13.0
- 2.12.0
- 2.11.2
- 2.11.1
- 2.10.1
- 2.10.0
- 2.9.1
- 2.9
- 2.8.0
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6
- 2.5
- 2.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.9.1
- v1.6.1
- v1.4.5
- 0.4.0
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2
- v0.1
- dev-fixing_non_string_option_creation
- dev-new_codestyle
- dev-listener-use-factories
- dev-refactoring
This package is auto-updated.
Last update: 2022-07-29 08:56:19 UTC
README
With this plugin the customer can add additional info to the product like so:
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 localconfig/packages/_sylius.yaml
:
imports: ... - { resource: "@Brille24SyliusCustomerOptionsPlugin/Resources/config/app/config.yml" }
- Add the
routing.yml
to your localconfig/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.