Skip to content

Instantly share code, notes, and snippets.

View lchrusciel's full-sized avatar
🎯
Focusing

Łukasz Chruściel lchrusciel

🎯
Focusing
View GitHub Profile
@lchrusciel
lchrusciel / TwigRendererEngine.php
Last active March 9, 2024 09:34
Customization required to allow more then one add to cart button in Sylius (SymfonyForm fix version)
<?php
// src/Twig/Form/TwigRendererEngine.php
namespace App\Twig\Form;
use Symfony\Component\Form\AbstractRendererEngine;
use Symfony\Component\Form\FormView;
use Symfony\Component\VarDumper\VarDumper;
use Twig\Environment;
<?php
// src/Controller/BlogController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class BlogController extends AbstractController
@lchrusciel
lchrusciel / FreeItemPromotionActionCommand.php
Created May 15, 2024 19:16
Sample configuration of new promotion action
<?php
// src/Promotion/Action/FreeItemPromotionActionCommand.php
declare(strict_types=1);
namespace App\Promotion\Action;
use Sylius\Component\Promotion\Action\PromotionActionCommandInterface;
use Sylius\Component\Promotion\Model\PromotionInterface;
<service id="App\Promotion\Action\FreeItemPromotionActionCommand">
<tag name="sylius.promotion_action" type="free_item" label="app.form.promotion_action.free_item" form-type="App\Form\Type\Promotion\Action\FreeItemConfigurationType" />
</service>
<?php
// src/Promotion/Action/FreeItemPromotionActionCommand.php
declare(strict_types=1);
namespace App\Promotion\Action;
use Sylius\Bundle\PromotionBundle\Attribute\AsPromotionAction;
use Sylius\Component\Promotion\Action\PromotionActionCommandInterface;