first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace KupShop\OrderDiscountBundle\Twig\Components\Discounts\Handlers;
use KupShop\ComponentsBundle\Actions\Frontend\AbstractHandler;
use KupShop\ComponentsBundle\Attributes\Entrypoint;
use KupShop\ComponentsBundle\Twig\BaseComponent;
#[Entrypoint('checkout')]
abstract class AbstractOrderDiscount extends BaseComponent
{
public AbstractHandler $handler;
public function getIdAction(): int
{
return $this->handler->getActionId();
}
public function getName(): string
{
return "action_handler[{$this->handler->getActionId()}]";
}
public function getTitle(): string
{
return $this->handler->getOrderDiscount()->getDisplayName();
}
public function getFrontendData(): array
{
return $this->handler->getData();
}
public function getData(): array
{
return $this->handler->getActionData();
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace KupShop\OrderDiscountBundle\Twig\Components\Discounts\Handlers;
use KupShop\ComponentsBundle\Attributes\Component;
use KupShop\ComponentsBundle\Attributes\Version;
use KupShop\ComponentsBundle\Entity\Thumbnail;
use KupShop\ComponentsBundle\Twig\DataProvider\ProductDataProvider;
use Symfony\Contracts\Service\Attribute\Required;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
#[AsTwigComponent(template: '@OrderDiscount/components/Discounts/Upsell/Upsell.1.html.twig')]
#[Component(1, [
new Version(1, newJs: null),
])]
class Upsell extends AbstractOrderDiscount
{
#[Required]
public ProductDataProvider $provider;
public array $id_products = [];
private ?\Product $mainProduct = null;
public function getThumbnail()
{
$product = $this->getMainProduct();
return new Thumbnail($product->photoId, $product->photoDescr, $product->photoDateUpdate);
}
public function getDescription()
{
return $this->data['description'] ?? '';
}
public function getPrice()
{
return $this->getMainProduct()->getProductPrice();
}
protected function getMainProduct(): \Product
{
if (is_null($this->mainProduct)) {
foreach ($this->id_products as $id_product) {
$product = $this->provider->getProduct($id_product);
if ($this->mainProduct === null || $product->getProductPrice()->getPriceWithVat()->lowerThan($this->mainProduct->getProductPrice()->getPriceWithVat())) {
$this->mainProduct = $product;
}
}
}
return $this->mainProduct;
}
}