4
4
5
5
use Mond1SWR5 \Components \PluginConfig \Service \ConfigService ;
6
6
use Mond1SWR5 \Enum \PaymentMethods ;
7
+ use Mond1SWR5 \Services \OrderServices \AbstractOrderAdditionalCostsService ;
7
8
use Monolog \Logger ;
8
9
use Shopware \Components \HttpClient \RequestException ;
9
10
use Shopware \Components \Model \ModelManager ;
@@ -43,20 +44,27 @@ class OrderHelper
43
44
*/
44
45
private $ customerHelper ;
45
46
47
+ /**
48
+ * @var AbstractOrderAdditionalCostsService
49
+ */
50
+ private $ orderAdditionalCostsService ;
51
+
46
52
public function __construct (
47
53
ModelManager $ modelManager ,
48
54
DocumentHelper $ documentHelper ,
49
55
Logger $ logger ,
50
56
ConfigService $ configService ,
51
57
CartHelper $ cartHelper ,
52
- CustomerHelper $ customerHelper
58
+ CustomerHelper $ customerHelper ,
59
+ AbstractOrderAdditionalCostsService $ orderAdditionalCostsService
53
60
) {
54
61
$ this ->modelManager = $ modelManager ;
55
62
$ this ->documentHelper = $ documentHelper ;
56
63
$ this ->logger = $ logger ;
57
64
$ this ->configService = $ configService ;
58
65
$ this ->cartHelper = $ cartHelper ;
59
66
$ this ->customerHelper = $ customerHelper ;
67
+ $ this ->orderAdditionalCostsService = $ orderAdditionalCostsService ;
60
68
}
61
69
62
70
public function canShipOrder ($ order ): bool
@@ -72,7 +80,7 @@ public function canShipOrder($order): bool
72
80
*/
73
81
public function shipOrder ($ order ) {
74
82
/**
75
- * @var MonduClient
83
+ * @var $client MonduClient
76
84
*/
77
85
$ client = Shopware ()->Container ()->get (MonduClient::class);
78
86
@@ -195,6 +203,7 @@ public function getOrderFromOrderVariables($orderVariables) {
195
203
'lines ' => [
196
204
[
197
205
'discount_cents ' => $ this ->getTotalDiscount ($ content , $ chargeVat ),
206
+ 'buyer_fee_cents ' => $ this ->orderAdditionalCostsService ->getAdditionalCostsCentsFromOrderVariables ($ orderVariables ),
198
207
'shipping_price_cents ' => round ($ shippingAmount * 100 ),
199
208
'line_items ' => $ this ->removeDuplicateSwReferenceIds ($ this ->getLineItems ($ content , $ chargeVat ))
200
209
]
@@ -238,6 +247,7 @@ public function getOrderAdjustment($order) {
238
247
'lines ' => [
239
248
[
240
249
'discount_cents ' => $ totalDiscountGross ,
250
+ 'buyer_fee_cents ' => $ this ->orderAdditionalCostsService ->getAdditionalCostsCentsFromOrder ($ order ),
241
251
'shipping_price_cents ' => round ($ order ->getInvoiceShipping () * 100 ),
242
252
'line_items ' => $ this ->removeDuplicateSwReferenceIds ($ lineitems )
243
253
]
@@ -336,18 +346,19 @@ public function getInvoiceCreateState()
336
346
}
337
347
338
348
private function getBuyerParams ($ userData ) {
339
- $ params = $ userData ['additional ' ]['user ' ];
349
+ $ user = $ userData ['additional ' ]['user ' ];
340
350
$ billing = $ userData ['billingaddress ' ];
341
351
342
- $ phone = !$ billing ['phone ' ] ? null : (trim ($ billing ['phone ' ]) ?: null );
343
-
344
352
return [
345
- 'email ' => $ params ['email ' ],
346
- 'phone ' => $ phone ,
353
+ 'email ' => $ user ['email ' ],
354
+ 'first_name ' => $ user ['firstname ' ],
355
+ 'last_name ' => $ user ['lastname ' ],
347
356
'company_name ' => $ billing ['company ' ],
348
- 'first_name ' => $ billing ['firstname ' ] ,
349
- 'last_name ' => $ billing [ ' lastname ' ],
357
+ 'phone ' => ! $ billing ['phone ' ] ? null : ( trim ( $ billing [ ' phone ' ]) ?: null ) ,
358
+ 'is_registered ' => ( bool ) $ user [ ' userID ' ],
350
359
'salutation ' => $ billing ['salutation ' ],
360
+ 'created_at ' => $ user ['firstlogin ' ] . ' 00:00:00 ' ,
361
+ 'updated_at ' => $ user ['changed ' ],
351
362
'address_line1 ' => $ billing ['street ' ]
352
363
];
353
364
}
0 commit comments