- Notifications
You must be signed in to change notification settings - Fork37
A Sylius plugin that adds customer options
License
NotificationsYou must be signed in to change notification settings
Brille24/SyliusCustomOptionsPlugin
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
With this plugin the customer can add additional info to the product like so:
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"sylius_shop_ajax_cart_add_item:path:ajax/cart/addmethods:[POST]defaults:_controller:sylius.controller.order_item::addAction_format:json_sylius:factory:method:createForProductWithCustomerOptionarguments:[expr:notFoundOnNull(service('sylius.repository.product').find($productId))]form:type:Sylius\Bundle\CoreBundle\Form\Type\Order\AddToCartTypeoptions:product:expr:notFoundOnNull(service('sylius.repository.product').find($productId))redirect:route:sylius_shop_cart_summaryparameters:{}flash:sylius.cart.add_itemsylius_shop_partial_cart_add_item:path:cart/add-itemmethods:[GET]defaults:_controller:sylius.controller.order_item::addAction_sylius:template:$templatefactory:method:createForProductWithCustomerOptionarguments:[expr:notFoundOnNull(service('sylius.repository.product').find($productId))]form:type:Sylius\Bundle\CoreBundle\Form\Type\Order\AddToCartTypeoptions:product:expr:notFoundOnNull(service('sylius.repository.product').find($productId))redirect:route:sylius_shop_cart_summaryparameters:{}
- Copy the template overrides from the plugin directory
From: [shop_dir]/vendor/brille24/sylius-customer-options-plugin/test/Application/templatesTo: [shop_dir]/templates
In order to use the customer options, you need to override the product and order item.
useBrille24\SyliusCustomerOptionsPlugin\Entity\ProductInterface;useBrille24\SyliusCustomerOptionsPlugin\Traits\ProductCustomerOptionCapableTrait;useSylius\Component\Core\Model\ProductasBaseProduct;class Productextends BaseProductimplements ProductInterface {use ProductCustomerOptionCapableTrait { __constructasprotected customerOptionCapableConstructor; }publicfunction__construct() {parent::__construct();$this->customerOptionCapableConstructor(); }// ...}
useBrille24\SyliusCustomerOptionsPlugin\Entity\OrderItemInterface;useBrille24\SyliusCustomerOptionsPlugin\Traits\OrderItemCustomerOptionCapableTrait;useSylius\Component\Core\Model\OrderItemasBaseOrderItem;class OrderItemextends BaseOrderItemimplements OrderItemInterface{use OrderItemCustomerOptionCapableTrait { __constructasprotected customerOptionCapableConstructor; }publicfunction__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, generate migrations, update the database and update the translations:
bin/console doctrine:migrations:diffbin/console doctrine:migrations:migratebin/console translation:update
- Saving files as customer defined values as the values are currently stored as a string in the database
When developing it is recommended to use git hooks for this just copy thedocs/pre-commit
to.git/hooks/pre-commit
and make it executable. Then you will check your codestyle before committing.
Documentation on how to use the plugin can be foundhere.
About
A Sylius plugin that adds customer options
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.