arobases-sylius-public / sylius-professional-customer-plugin
Plugin allowing to add professional customer to your shop
Installs: 2 099
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:sylius-plugin
Requires
- sylius/sylius: ^1.9
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-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: ^1.6 || >2.0.0-alpha.0 ^2.0@dev
- lakion/mink-debug-extension: ^2.0.0
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.74
- phpstan/phpstan-doctrine: 0.12.31
- phpstan/phpstan-strict-rules: ^0.12.0
- 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: ^3.1
- symfony/browser-kit: ^4.4 || ^5.2
- symfony/debug-bundle: ^4.4 || ^5.2
- symfony/dotenv: ^4.4 || ^5.2
- symfony/intl: ^4.4 || ^5.2
- symfony/web-profiler-bundle: ^4.4 || ^5.2
- vimeo/psalm: 4.4.1
This package is auto-updated.
Last update: 2024-10-21 15:29:43 UTC
README
1. Require plugin with composer:
composer require arobases-sylius-public/sylius-professional-customer-plugin
3. Import configuration:
#config/packages/arobases_sylius_professional_customer_plugin.yaml imports: - { resource: "@ArobasesSyliusProfessionalCustomerPlugin/Resources/config/config.yaml" }
4. Import routing:
# config/routes.yaml arobases_sylius_professional_customer_plugin_shop: resource: "@ArobasesSyliusProfessionalCustomerPlugin/Resources/config/shop_routing.yml" prefix: /{_locale} requirements: _locale: ^[a-z]{2}(?:_[A-Z]{2})?$ arobases_sylius_professional_customer_plugin_admin: resource: "@ArobasesSyliusProfessionalCustomerPlugin/Resources/config/admin_routing.yml" prefix: /admin
5. Add plugin class to your bundles.php:
$bundles = [ // ... Arobases\SyliusProfessionalCustomerPlugin\ArobasesSyliusProfessionalCustomerPlugin::class => ['all' => true], // ... ];
5. Use CustomerTrait and CustomerInterface:
<?php //src/Entity/Customer/Customer.php declare(strict_types=1); namespace App\Entity\Customer; use Arobases\SyliusProfessionalCustomerPlugin\Model\CustomerInterface; use Arobases\SyliusProfessionalCustomerPlugin\Model\CustomerTrait; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Customer as BaseCustomer; /** * @ORM\Entity * @ORM\Table(name="sylius_customer") */ class Customer extends BaseCustomer implements CustomerInterface { use CustomerTrait; }
6. Use ChannelTrait and ChannelInterface:
<?php //src/Entity/Channel/Channel.php declare(strict_types=1); namespace App\Entity\Channel; use Arobases\SyliusProfessionalCustomerPlugin\Model\ChannelInterface; use Arobases\SyliusProfessionalCustomerPlugin\Model\ChannelTrait; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Channel as BaseChannel; /** * @ORM\Entity * @ORM\Table(name="sylius_channel") */ class Channel extends BaseChannel implements ChannelInterface { use ChannelTrait; }
7. Update the schema
php bin/console doctrine:schema:update --force
8. Copy templates
8.1 Copy Channel templates
Extend the Channel Admin Form template
vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/views/Channel/_form.html.twig
And Add considerTaxesForProfessionalCustomer form
{# templates/bundles/SyliusAdminBundle/Channel/_form.html.twig #} {{ form_row(form.considerTaxesForProfessionalCustomer) }}
8.2 Copy Customer templates
Extend the Customer Admin Form template
vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/views/Customer/_form.html.twig
And Add considerTaxesForProfessionalCustomer form
{# templates/bundles/SyliusAdminBundle/Customer/_form.html.twig #} {{ form_row(form.isPro) }}
{% if customer.isPro == true %} <div class="ui segment"> <h4 class="ui dividing header">{{ 'arobases_sylius_professional_customer.ui.professional_information'|trans }}</h4> {{ form_row(form.isProVerified) }} {{ form_row(form.businessRegistrationNumber) }} {{ form_row(form.socialReason) }} {{ form_row(form.vatNumber) }} </div> {% if customer.filePath is not null %} <div class="ui segment"> <h4 class="ui dividing header">{{ 'arobases_sylius_professional_customer.ui.kbis'|trans }}</h4> <object type="application/pdf" width="100%" height="100%"> <param name="src" value="{{ asset(customer.filePath) }}" /> {{ 'arobases_sylius_professional_customer.ui.display_fail'|trans }} </object> <a href="{{ asset(customer.filePath) }}">{{ 'arobases_sylius_professional_customer.ui.download'|trans }}</a> </div> {% endif %} {% endif %}
8.3 Copy Menu templates
Extend the Menu template
vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Menu/_security.html.twig
{# templates/bundles/SyliusShopBundle/Menu/_security.html.twig #} <div class="ui right stackable inverted menu"> {% if is_granted('ROLE_USER') %} <div class="item" {{ sylius_test_html_attribute('full-name') }}>{{ 'sylius.ui.hello'|trans }} {{ app.user.customer.fullName }}!</div> {% if true == app.user.customer.isPro %} <a href="{{ path('sylius_shop_account_dashboard') }}" class="item">{{ 'arobases_sylius_professional_customer.ui.my_account'|trans }}</a> {% else %} <a href="{{ path('sylius_shop_account_dashboard') }}" class="item">{{ 'sylius.ui.my_account'|trans }}</a> {% endif %} <a href="{{ path('sylius_shop_logout') }}" class="item sylius-logout-button" {{ sylius_test_html_attribute('logout-button') }}>{{ 'sylius.ui.logout'|trans }}</a> {% else %} <a href="{{ path('sylius_shop_login') }}" class="item">{{ 'sylius.ui.login'|trans }}</a> <a href="{{ path('sylius_shop_register') }}" class="item">{{ 'sylius.ui.register'|trans }}</a> <a href="{{ path('sylius_pro_shop_register') }}" class="item">{{ 'arobases_sylius_professional_customer.ui.register'|trans }}</a> {% endif %} </div>