Skip to content

Commit 9b33434

Browse files
committed
Added view_cart event
1 parent 67bf82f commit 9b33434

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Setono\GoogleAnalyticsMeasurementProtocol\Request\Body\Event;
6+
7+
use Setono\GoogleAnalyticsMeasurementProtocol\Request\Body\Event\Item\Item;
8+
use Setono\GoogleAnalyticsMeasurementProtocol\Request\Body\Event\Trait\CreatesEmpty;
9+
use Setono\GoogleAnalyticsMeasurementProtocol\Request\Body\Event\Trait\HasCurrency;
10+
use Setono\GoogleAnalyticsMeasurementProtocol\Request\Body\Event\Trait\HasItems;
11+
use Setono\GoogleAnalyticsMeasurementProtocol\Request\Body\Event\Trait\HasValue;
12+
13+
class ViewCartEvent extends Event
14+
{
15+
use CreatesEmpty;
16+
use HasCurrency;
17+
use HasValue;
18+
use HasItems;
19+
20+
public function getEventName(): string
21+
{
22+
return 'view_cart';
23+
}
24+
25+
protected function getParameters(): array
26+
{
27+
return [
28+
'currency' => $this->currency,
29+
'value' => $this->value,
30+
'items' => array_map(static fn (Item $item) => $item->getParameters(), $this->items),
31+
];
32+
}
33+
}

0 commit comments

Comments
 (0)