Files
kupshop/bundles/KupShop/GTMOldBundle/Ecommerce/RemoveFromCart.php
2025-08-02 16:30:27 +02:00

39 lines
1.1 KiB
PHP

<?php
namespace KupShop\GTMOldBundle\Ecommerce;
use KupShop\GTMOldBundle\Utils\PriceComputer;
class RemoveFromCart extends AbstractEcommerce
{
/**
* @var PriceComputer
*/
protected $priceComputer;
public function __construct(PriceComputer $priceComputer)
{
$this->priceComputer = $priceComputer;
}
/**
* Specific PageData.
*/
public function getData(&$dataContainer)
{
foreach ($this->pageData['products'] as $product) {
$id = !empty($product['id_variation']) ? ($product['id'].'_'.$product['id_variation']) : $product['id'];
$dataContainer->{$id} = [
'name' => $product['product']->title,
'id' => $id,
'price' => $this->priceComputer->getPrice($product['price']),
'brand' => $product['producer'],
// 'category' => $product['section_name'], TODO: neni zatim odkud vzit?
'variant' => $product['product']->variationTitle ?? '',
'quantity' => $product['pieces'],
];
}
}
}