Skip to content

Commit c9d2434

Browse files
author
Serhiy Shkolyarenko
committed
MAGETWO-38644: Output data Estimated Total and Cart Items Count on Checkout
added view model minor fixes for item details
1 parent f0b59a5 commit c9d2434

File tree

6 files changed

+65
-28
lines changed

6 files changed

+65
-28
lines changed

app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
<item name="component" xsi:type="string">Magento_Checkout/js/view/progress-bar</item>
4747
<item name="displayArea" xsi:type="string">progressBar</item>
4848
</item>
49+
<item name="estimation" xsi:type="array">
50+
<item name="sortOrder" xsi:type="string">10</item>
51+
<item name="component" xsi:type="string">Magento_Checkout/js/view/estimation</item>
52+
<item name="displayArea" xsi:type="string">estimation</item>
53+
<item name="config" xsi:type="array">
54+
<item name="template" xsi:type="string">Magento_Checkout/estimation</item>
55+
</item>
56+
</item>
4957
<item name="steps" xsi:type="array">
5058
<item name="component" xsi:type="string">uiComponent</item>
5159
<item name="displayArea" xsi:type="string">steps</item>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define(
6+
[
7+
'Magento_Checkout/js/view/summary/abstract-total',
8+
'Magento_Checkout/js/model/totals'
9+
],
10+
function (Component, totals) {
11+
'use strict';
12+
return Component.extend({
13+
getQuantity: function() {
14+
if (totals.totals()) {
15+
return parseFloat(totals.totals().items_qty);
16+
}
17+
return 0;
18+
},
19+
getPureValue: function() {
20+
if (totals.totals()) {
21+
return parseFloat(totals.getSegment('grand_total').value);
22+
}
23+
return 0;
24+
},
25+
getValue: function () {
26+
return this.getFormattedPrice(this.getPureValue());
27+
}
28+
29+
});
30+
}
31+
);
32+

app/code/Magento/Checkout/view/frontend/web/js/view/summary/cart-items.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ define(
2121
totals: totals.totals(),
2222
getItems: totals.getItems(),
2323
getItemsQty: function() {
24-
return parseInt(this.totals.items_qty) || 0;
24+
return parseFloat(this.totals.items_qty);
2525
},
2626
isItemsBlockExpanded: function () {
2727
return quote.isVirtual() || stepNavigator.isProcessed('shipping');

app/code/Magento/Checkout/view/frontend/web/js/view/summary/item/details.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
/*global alert*/
77
define(
88
[
9-
'uiComponent',
10-
'../../../model/quote',
11-
'Magento_Catalog/js/price-utils'
9+
'uiComponent'
1210
],
13-
function (Component, quote, priceUtils) {
11+
function (Component) {
1412
"use strict";
1513
return Component.extend({
1614
defaults: {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div class="opc-estimated-wrapper">
8+
<div class="estimated-block">
9+
<span class="estimated-label" data-bind="text: $t('Estimated Total')"></span>
10+
<span class="estimated-price" data-bind="text: getValue()">$120.00</span>
11+
</div>
12+
<div class="minicart-wrapper">
13+
<button type="button" class="action showcart" data-toggle="opc-summary">
14+
<span class="counter qty">
15+
<span class="counter-number" data-bind="text: getQuantity()"></span>
16+
</span>
17+
</button>
18+
</div>
19+
</div>

app/code/Magento/Checkout/view/frontend/web/template/onepage.html

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,9 @@
1212
<!-- ko template: getTemplate() --><!-- /ko -->
1313
<!--/ko-->
1414

15-
<!-- Temp MAGETWO-36025 markup -->
16-
<div class="opc-estimated-wrapper">
17-
<!-- Markup for MAGETWO-38644 -->
18-
<div class="estimated-block">
19-
<span class="estimated-label" data-bind="text: $t('Estimated Total')"></span>
20-
<span class="estimated-price">$100.00</span>
21-
</div>
22-
<div class="minicart-wrapper">
23-
<button type="button" class="action showcart" data-toggle="opc-summary">
24-
<span class="counter qty">
25-
<span class="counter-number">6</span>
26-
</span>
27-
</button>
28-
</div>
29-
<!-- Temp MAGETWO-36025 markup
30-
<button
31-
type="button"
32-
class="action showcart"
33-
data-toggle="opc-summary">
34-
<span data-bind="text: $t('View order summary')"></span>
35-
</button>-->
36-
</div>
37-
<!-- /Temp MAGETWO-36025 markup -->
15+
<!-- ko foreach: getRegion('estimation') -->
16+
<!-- ko template: getTemplate() --><!-- /ko -->
17+
<!--/ko-->
3818

3919
<!-- ko foreach: getRegion('messages') -->
4020
<!-- ko template: getTemplate() --><!-- /ko -->

0 commit comments

Comments
 (0)