-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customise Product as packable or not
- Loading branch information
Showing
4 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Form\Extension; | ||
|
||
use Sylius\Bundle\ProductBundle\Form\Type\ProductType; | ||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
final class ProductTypeExtension extends AbstractTypeExtension | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('packable', CheckboxType::class) | ||
; | ||
} | ||
|
||
public static function getExtendedTypes(): iterable | ||
{ | ||
yield ProductType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20240508114451 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE sylius_product ADD packable TINYINT(1) DEFAULT 0 NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE sylius_product DROP packable'); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationFormWithSlug %} | ||
|
||
<div class="ui active tab" data-tab="details"> | ||
<h3 class="ui top attached header">{{ 'sylius.ui.details'|trans }}</h3> | ||
|
||
<div class="ui attached segment"> | ||
{{ form_errors(form) }} | ||
|
||
<div class="ui two column stackable grid"> | ||
<div class="column"> | ||
<div class="ui segment"> | ||
{{ form_row(form.code) }} | ||
{{ form_row(form.enabled) }} | ||
{% if product.simple %} | ||
{{ form_row(form.variant.shippingRequired) }} | ||
{% else %} | ||
{{ form_row(form.options, {'remote_url': path('sylius_admin_ajax_product_options_by_phrase'), 'load_edit_url': path('sylius_admin_ajax_find_product_options')}) }} | ||
{{ form_row(form.variantSelectionMethod) }} | ||
{% endif %} | ||
|
||
{# Nothing to see here. #} | ||
<div class="ui hidden element"> | ||
{% if product.simple %} | ||
{{ form_row(form.variant.translations) }} | ||
{{ form_row(form.variantSelectionMethod) }} | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="column"> | ||
{{ form_row(form.channels) }} | ||
{{ form_row(form.packable) }} | ||
</div> | ||
</div> | ||
{% if product.simple %} | ||
<div class="ui one column stackable grid"> | ||
<div class="column"> | ||
<h4 class="ui dividing header">{{ 'sylius.ui.pricing'|trans }}</h4> | ||
{% include "@SyliusAdmin/Product/_channel_pricing.html.twig" with { product: product, variantForm: form.variant } only %} | ||
</div> | ||
</div> | ||
{% endif %} | ||
<div class="ui hidden divider"></div> | ||
{{ translationFormWithSlug(form.translations, '@SyliusAdmin/Product/_slugField.html.twig', product) }} | ||
{% if product.simple %} | ||
<div class="ui hidden divider"></div> | ||
<div class="ui two column stackable grid"> | ||
<div class="column"> | ||
<h4 class="ui top attached header">{{ 'sylius.ui.shipping'|trans }}</h4> | ||
<div class="ui attached segment"> | ||
{{ form_row(form.variant.shippingCategory) }} | ||
{{ form_row(form.variant.width) }} | ||
{{ form_row(form.variant.height) }} | ||
{{ form_row(form.variant.depth) }} | ||
{{ form_row(form.variant.weight) }} | ||
</div> | ||
</div> | ||
<div class="column"> | ||
<h4 class="ui top attached header">{{ 'sylius.ui.taxes'|trans }}</h4> | ||
<div class="ui attached segment"> | ||
{{ form_row(form.variant.taxCategory) }} | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
|
||
{{ sylius_template_event(['sylius.admin.product.' ~ action ~ '.tab_details', 'sylius.admin.product.tab_details'], {'form': form}) }} | ||
</div> | ||
</div> |