-
Notifications
You must be signed in to change notification settings - Fork 1
/
Index.php
45 lines (37 loc) · 1.3 KB
/
Index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Taggrs\DataLayer\Controller\AddPaymentInfo;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Store\Model\StoreManagerInterface;
use Taggrs\DataLayer\Controller\AbstractDataLayerController;
use Taggrs\DataLayer\Helper\QuoteDataHelper;
use Taggrs\DataLayer\Helper\UserDataHelper;
class Index extends AbstractDataLayerController
{
private QuoteDataHelper $quoteDataHelper;
public function __construct(
Context $context,
JsonFactory $resultJsonFactory,
QuoteDataHelper $quoteDataHelper,
UserDataHelper $userDataHelper,
StoreManagerInterface $storeManager
) {
parent::__construct($context, $resultJsonFactory, $userDataHelper, $storeManager);
$this->quoteDataHelper = $quoteDataHelper;
$this->storeManager = $storeManager;
}
public function getEvent(): string
{
return 'add_payment_info';
}
public function getEcommerce(): array
{
$total = $this->quoteDataHelper->getQuote()->getGrandTotal();
return [
'currency' => $this->getCurrency(),
'value' => $total,
'items' => $this->quoteDataHelper->getItemsFromQuote(true, true),
'user_data' => $this->getUserData(),
];
}
}