1- <?php declare (strict_types= 1 );
1+ <?php
22
33/**
44 * Copyright © Itonomy BV. All rights reserved.
55 * See LICENSE.md for license details.
66 */
7-
87namespace Itonomy \Flowbox \Block \Checkout \Onepage ;
98
9+ use Itonomy \Flowbox \Helper \Data ;
10+ use Magento \Checkout \Model \Session ;
11+ use Magento \Cookie \Helper \Cookie ;
12+ use Magento \Framework \Encryption \EncryptorInterface ;
13+ use Magento \Framework \View \Element \Template \Context ;
14+ use Magento \Catalog \Model \ProductRepository ;
15+
1016class Success extends \Itonomy \Flowbox \Block \Base
1117{
1218 /**
13- * @var \Magento\Checkout\Model\ Session
19+ * @var Session
1420 */
1521 private $ checkoutSession ;
1622
23+ /**
24+ * @var Data
25+ */
26+ private $ helper ;
27+
28+ /**
29+ * @var ProductRepository
30+ */
31+ private $ productRepository ;
32+
1733 /**
1834 * Success constructor.
19- * @param \Magento\Framework\View\Element\Template\Context $context
20- * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
21- * @param \Magento\Checkout\Model\Session $checkoutSession
35+ * @param Context $context
36+ * @param EncryptorInterface $encryptor
37+ * @param Cookie $cookie
38+ * @param Session $checkoutSession
39+ * @param ProductRepository $productRepository
40+ * @param Data $helper
2241 * @param array $data
2342 */
2443 public function __construct (
25- \Magento \Framework \View \Element \Template \Context $ context ,
26- \Magento \Framework \Encryption \EncryptorInterface $ encryptor ,
27- \Magento \Checkout \Model \Session $ checkoutSession ,
44+ Context $ context ,
45+ EncryptorInterface $ encryptor ,
46+ Cookie $ cookie ,
47+ Session $ checkoutSession ,
48+ ProductRepository $ productRepository ,
49+ Data $ helper ,
2850 array $ data = []
2951 ) {
30- parent ::__construct ($ context , $ encryptor , $ data );
52+ parent ::__construct ($ context , $ cookie , $ encryptor , $ data );
53+ $ this ->helper = $ helper ;
3154 $ this ->checkoutSession = $ checkoutSession ;
55+ $ this ->productRepository = $ productRepository ;
3256 }
3357
3458 /**
@@ -39,14 +63,17 @@ protected function prepareConfig(): void
3963 try {
4064 $ order = $ this ->checkoutSession ->getLastRealOrder ();
4165
66+
4267 $ this ->setData ('flowbox ' , [
43- 'debug ' => $ this ->isDebugJavaScript (),
68+ 'allowCookies ' => $ this ->isUserAllowSaveCookies (),
4469 'apiKey ' => (string ) $ this ->getApiKey (),
70+ 'debug ' => $ this ->isDebugJavaScript (),
4571 'orderId ' => \ltrim ($ order ->getIncrementId (), '# ' ),
4672 'products ' => \array_map (
47- function ($ item ) {
73+ function ($ item ){
74+ $ product = $ this ->productRepository ->get ($ item ->getSku ());
4875 return [
49- 'id ' => (string ) $ item -> getSku ( ),
76+ 'id ' => (string ) $ product -> getData ( $ this -> helper -> getAttributeCode () ),
5077 'quantity ' => (int ) $ item ->getQtyOrdered ()
5178 ];
5279 },
@@ -80,4 +107,4 @@ protected function getAllVisibleItems($order)
80107 }
81108 return $ items ;
82109 }
83- }
110+ }
0 commit comments