Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Sylius plugin that adds customer options

License

NotificationsYou must be signed in to change notification settings

Brille24/SyliusCustomOptionsPlugin

Repository files navigation

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

Installation

  • Runcomposer require brille24/sylius-customer-options-plugin.

  • Register the Plugin in yourconfig/bundles.php:

return [//...Brille24\SyliusCustomerOptionsPlugin\Brille24SyliusCustomerOptionsPlugin::class => ['all' =>true],];
  • Add theconfig.yml to your localconfig/packages/_sylius.yaml:
imports:...    -{ resource: "@Brille24SyliusCustomerOptionsPlugin/Resources/config/app/config.yml" }
  • Add therouting.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 thebrille24_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

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 thedocs/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 foundhere.

About

A Sylius plugin that adds customer options

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors30


[8]ページ先頭

©2009-2025 Movatter.jp