Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit fbb6626

Browse files
committed
Show cart item subtotal instead of total in Cart and Checkout blocks (#3905)
* Show cart item subtotal instead of total in Cart and Checkout blocks * Update test that would have caught this error
1 parent e6c1c66 commit fbb6626

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

assets/js/base/components/cart-checkout/order-summary/order-summary-item.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ const OrderSummaryItem = ( { cartItem } ) => {
7878
.getAmount();
7979
const totalsCurrency = getCurrencyFromPriceResponse( totals );
8080

81-
let lineTotal = parseInt( totals.line_total, 10 );
81+
let lineSubtotal = parseInt( totals.line_subtotal, 10 );
8282
if ( DISPLAY_CART_PRICES_INCLUDING_TAX ) {
83-
lineTotal += parseInt( totals.line_total_tax, 10 );
83+
lineSubtotal += parseInt( totals.line_subtotal_tax, 10 );
8484
}
85-
const totalsPrice = Dinero( {
86-
amount: lineTotal,
85+
const subtotalPrice = Dinero( {
86+
amount: lineSubtotal,
8787
precision: totalsCurrency.minorUnit,
8888
} ).getAmount();
8989
const subtotalPriceFormat = __experimentalApplyCheckoutFilter( {
@@ -153,7 +153,7 @@ const OrderSummaryItem = ( { cartItem } ) => {
153153
<ProductPrice
154154
currency={ totalsCurrency }
155155
format={ productPriceFormat }
156-
price={ totalsPrice }
156+
price={ subtotalPrice }
157157
/>
158158
</div>
159159
</div>

assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ const CartLineItemRow = ( { lineItem = {} } ) => {
8686
currency_suffix: '',
8787
currency_decimal_separator: '.',
8888
currency_thousand_separator: ',',
89-
line_total: '0',
90-
line_total_tax: '0',
89+
line_subtotal: '0',
90+
line_subtotal_tax: '0',
9191
},
9292
extensions,
9393
} = lineItem;
@@ -132,12 +132,12 @@ const CartLineItemRow = ( { lineItem = {} } ) => {
132132
);
133133
const saleAmount = saleAmountSingle.multiply( quantity );
134134
const totalsCurrency = getCurrencyFromPriceResponse( totals );
135-
let lineTotal = parseInt( totals.line_total, 10 );
135+
let lineSubtotal = parseInt( totals.line_subtotal, 10 );
136136
if ( DISPLAY_CART_PRICES_INCLUDING_TAX ) {
137-
lineTotal += parseInt( totals.line_total_tax, 10 );
137+
lineSubtotal += parseInt( totals.line_subtotal_tax, 10 );
138138
}
139-
const totalsPrice = Dinero( {
140-
amount: lineTotal,
139+
const subtotalPrice = Dinero( {
140+
amount: lineSubtotal,
141141
precision: totalsCurrency.minorUnit,
142142
} );
143143

@@ -260,7 +260,7 @@ const CartLineItemRow = ( { lineItem = {} } ) => {
260260
<ProductPrice
261261
currency={ totalsCurrency }
262262
format={ productPriceFormat }
263-
price={ totalsPrice.getAmount() }
263+
price={ subtotalPrice.getAmount() }
264264
/>
265265

266266
{ quantity > 1 && (

assets/js/blocks/cart-checkout/cart/test/block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe( 'Testing cart', () => {
8686
currency_prefix: '',
8787
currency_suffix: '€',
8888
line_subtotal: '16',
89-
line_total: '16',
89+
line_total: '18',
9090
},
9191
},
9292
],

0 commit comments

Comments
 (0)