3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Multishipping \Block \Checkout ;
7
8
8
9
use Magento \Framework \Pricing \PriceCurrencyInterface ;
12
13
* Multishipping checkout overview information
13
14
*
14
15
* @api
15
- * @author Magento Core Team <core@magentocommerce.com>
16
- * @since 100.0.2
16
+ * @author Magento Core Team <core@magentocommerce.com>
17
+ * @since 100.0.2
17
18
*/
18
19
class Overview extends \Magento \Sales \Block \Items \AbstractItems
19
20
{
@@ -48,13 +49,13 @@ class Overview extends \Magento\Sales\Block\Items\AbstractItems
48
49
protected $ totalsReader ;
49
50
50
51
/**
51
- * @param \Magento\Framework\View\Element\Template\Context $context
52
+ * @param \Magento\Framework\View\Element\Template\Context $context
52
53
* @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping
53
- * @param \Magento\Tax\Helper\Data $taxHelper
54
- * @param PriceCurrencyInterface $priceCurrency
55
- * @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
56
- * @param \Magento\Quote\Model\Quote\TotalsReader $totalsReader
57
- * @param array $data
54
+ * @param \Magento\Tax\Helper\Data $taxHelper
55
+ * @param PriceCurrencyInterface $priceCurrency
56
+ * @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
57
+ * @param \Magento\Quote\Model\Quote\TotalsReader $totalsReader
58
+ * @param array $data
58
59
*/
59
60
public function __construct (
60
61
\Magento \Framework \View \Element \Template \Context $ context ,
@@ -74,6 +75,37 @@ public function __construct(
74
75
$ this ->totalsReader = $ totalsReader ;
75
76
}
76
77
78
+ /**
79
+ * Overwrite the total value of shipping amount for viewing purpose
80
+ *
81
+ * @param array $totals
82
+ * @return mixed
83
+ * @throws \Exception
84
+ */
85
+ private function getMultishippingTotals ($ totals )
86
+ {
87
+ if (isset ($ totals ['shipping ' ]) && !empty ($ totals ['shipping ' ])) {
88
+ $ total = $ totals ['shipping ' ];
89
+ $ shippingMethod = $ total ->getAddress ()->getShippingMethod ();
90
+ if (isset ($ shippingMethod ) && !empty ($ shippingMethod )) {
91
+ $ shippingRate = $ total ->getAddress ()->getShippingRateByCode ($ shippingMethod );
92
+ $ shippingPrice = $ shippingRate ->getPrice ();
93
+ } else {
94
+ $ shippingPrice = $ total ->getAddress ()->getShippingAmount ();
95
+ }
96
+ /**
97
+ * @var \Magento\Store\Api\Data\StoreInterface
98
+ */
99
+ $ store = $ this ->getQuote ()->getStore ();
100
+ $ amountPrice = $ store ->getBaseCurrency ()
101
+ ->convert ($ shippingPrice , $ store ->getCurrentCurrencyCode ());
102
+ $ total ->setBaseShippingAmount ($ shippingPrice );
103
+ $ total ->setShippingAmount ($ amountPrice );
104
+ $ total ->setValue ($ amountPrice );
105
+ }
106
+ return $ totals ;
107
+ }
108
+
77
109
/**
78
110
* Initialize default item renderer
79
111
*
@@ -98,6 +130,8 @@ public function getCheckout()
98
130
}
99
131
100
132
/**
133
+ * Get billing address
134
+ *
101
135
* @return Address
102
136
*/
103
137
public function getBillingAddress ()
@@ -106,6 +140,8 @@ public function getBillingAddress()
106
140
}
107
141
108
142
/**
143
+ * Get payment info
144
+ *
109
145
* @return string
110
146
*/
111
147
public function getPaymentHtml ()
@@ -124,6 +160,8 @@ public function getPayment()
124
160
}
125
161
126
162
/**
163
+ * Get shipping addresses
164
+ *
127
165
* @return array
128
166
*/
129
167
public function getShippingAddresses ()
@@ -132,6 +170,8 @@ public function getShippingAddresses()
132
170
}
133
171
134
172
/**
173
+ * Get number of shipping addresses
174
+ *
135
175
* @return int|mixed
136
176
*/
137
177
public function getShippingAddressCount ()
@@ -145,8 +185,10 @@ public function getShippingAddressCount()
145
185
}
146
186
147
187
/**
148
- * @param Address $address
149
- * @return bool
188
+ * Get shipping address rate
189
+ *
190
+ * @param Address $address
191
+ * @return bool
150
192
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
151
193
*/
152
194
public function getShippingAddressRate ($ address )
@@ -159,27 +201,36 @@ public function getShippingAddressRate($address)
159
201
}
160
202
161
203
/**
162
- * @param Address $address
204
+ * Get shipping price including tax
205
+ *
206
+ * @param Address $address
163
207
* @return mixed
164
208
*/
165
209
public function getShippingPriceInclTax ($ address )
166
210
{
167
- $ exclTax = $ address ->getShippingAmount ();
211
+ $ rate = $ address ->getShippingRateByCode ($ address ->getShippingMethod ());
212
+ $ exclTax = $ rate ->getPrice ();
168
213
$ taxAmount = $ address ->getShippingTaxAmount ();
169
214
return $ this ->formatPrice ($ exclTax + $ taxAmount );
170
215
}
171
216
172
217
/**
173
- * @param Address $address
218
+ * Get shipping price excluding tax
219
+ *
220
+ * @param Address $address
174
221
* @return mixed
175
222
*/
176
223
public function getShippingPriceExclTax ($ address )
177
224
{
178
- return $ this ->formatPrice ($ address ->getShippingAmount ());
225
+ $ rate = $ address ->getShippingRateByCode ($ address ->getShippingMethod ());
226
+ $ shippingAmount = $ rate ->getPrice ();
227
+ return $ this ->formatPrice ($ shippingAmount );
179
228
}
180
229
181
230
/**
182
- * @param float $price
231
+ * Format price
232
+ *
233
+ * @param float $price
183
234
* @return mixed
184
235
*
185
236
* @codeCoverageIgnore
@@ -195,7 +246,9 @@ public function formatPrice($price)
195
246
}
196
247
197
248
/**
198
- * @param Address $address
249
+ * Get shipping address items
250
+ *
251
+ * @param Address $address
199
252
* @return array
200
253
*/
201
254
public function getShippingAddressItems ($ address ): array
@@ -204,7 +257,9 @@ public function getShippingAddressItems($address): array
204
257
}
205
258
206
259
/**
207
- * @param Address $address
260
+ * Get shipping address totals
261
+ *
262
+ * @param Address $address
208
263
* @return mixed
209
264
*/
210
265
public function getShippingAddressTotals ($ address )
@@ -223,6 +278,8 @@ public function getShippingAddressTotals($address)
223
278
}
224
279
225
280
/**
281
+ * Get total price
282
+ *
226
283
* @return float
227
284
*/
228
285
public function getTotal ()
@@ -231,6 +288,8 @@ public function getTotal()
231
288
}
232
289
233
290
/**
291
+ * Get the Edit addresses URL
292
+ *
234
293
* @return string
235
294
*/
236
295
public function getAddressesEditUrl ()
@@ -239,7 +298,9 @@ public function getAddressesEditUrl()
239
298
}
240
299
241
300
/**
242
- * @param Address $address
301
+ * Get the Edit shipping address URL
302
+ *
303
+ * @param Address $address
243
304
* @return string
244
305
*/
245
306
public function getEditShippingAddressUrl ($ address )
@@ -248,7 +309,9 @@ public function getEditShippingAddressUrl($address)
248
309
}
249
310
250
311
/**
251
- * @param Address $address
312
+ * Get the Edit billing address URL
313
+ *
314
+ * @param Address $address
252
315
* @return string
253
316
*/
254
317
public function getEditBillingAddressUrl ($ address )
@@ -257,6 +320,8 @@ public function getEditBillingAddressUrl($address)
257
320
}
258
321
259
322
/**
323
+ * Get the Edit shipping URL
324
+ *
260
325
* @return string
261
326
*/
262
327
public function getEditShippingUrl ()
@@ -265,6 +330,8 @@ public function getEditShippingUrl()
265
330
}
266
331
267
332
/**
333
+ * Get Post ACtion URL
334
+ *
268
335
* @return string
269
336
*/
270
337
public function getPostActionUrl ()
@@ -273,6 +340,8 @@ public function getPostActionUrl()
273
340
}
274
341
275
342
/**
343
+ * Get the Edit billing URL
344
+ *
276
345
* @return string
277
346
*/
278
347
public function getEditBillingUrl ()
@@ -281,6 +350,8 @@ public function getEditBillingUrl()
281
350
}
282
351
283
352
/**
353
+ * Get back button URL
354
+ *
284
355
* @return string
285
356
*/
286
357
public function getBackUrl ()
@@ -319,16 +390,20 @@ public function getQuote()
319
390
}
320
391
321
392
/**
393
+ * Get billin address totals
394
+ *
395
+ * @return mixed
322
396
* @deprecated
323
397
* typo in method name, see getBillingAddressTotals()
324
- * @return mixed
325
398
*/
326
399
public function getBillinAddressTotals ()
327
400
{
328
401
return $ this ->getBillingAddressTotals ();
329
402
}
330
403
331
404
/**
405
+ * Get billing address totals
406
+ *
332
407
* @return mixed
333
408
*/
334
409
public function getBillingAddressTotals ()
@@ -338,12 +413,17 @@ public function getBillingAddressTotals()
338
413
}
339
414
340
415
/**
341
- * @param mixed $totals
342
- * @param null $colspan
416
+ * Render total block
417
+ *
418
+ * @param mixed $totals
419
+ * @param null $colspan
343
420
* @return string
344
421
*/
345
422
public function renderTotals ($ totals , $ colspan = null )
346
423
{
424
+ //check if the shipment is multi shipment
425
+ $ totals = $ this ->getMultishippingTotals ($ totals );
426
+
347
427
if ($ colspan === null ) {
348
428
$ colspan = 3 ;
349
429
}
@@ -368,7 +448,7 @@ public function renderTotals($totals, $colspan = null)
368
448
/**
369
449
* Return row-level item html
370
450
*
371
- * @param \Magento\Framework\DataObject $item
451
+ * @param \Magento\Framework\DataObject $item
372
452
* @return string
373
453
*/
374
454
public function getRowItemHtml (\Magento \Framework \DataObject $ item )
@@ -382,7 +462,7 @@ public function getRowItemHtml(\Magento\Framework\DataObject $item)
382
462
/**
383
463
* Retrieve renderer block for row-level item output
384
464
*
385
- * @param string $type
465
+ * @param string $type
386
466
* @return \Magento\Framework\View\Element\AbstractBlock
387
467
*/
388
468
protected function _getRowItemRenderer ($ type )
0 commit comments