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

Commit cc5ac3b

Browse files
Aljulluopr
authored andcommitted
Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true (#3851)
* Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true * Show cart item total price including taxes in Checkout block too
1 parent ca39a8b commit cc5ac3b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getCurrency } from '@woocommerce/price-format';
99
import { __experimentalApplyCheckoutFilter } from '@woocommerce/blocks-checkout';
1010
import PropTypes from 'prop-types';
1111
import Dinero from 'dinero.js';
12+
import { DISPLAY_CART_PRICES_INCLUDING_TAX } from '@woocommerce/block-settings';
1213

1314
/**
1415
* Internal dependencies
@@ -60,8 +61,13 @@ const OrderSummaryItem = ( { cartItem } ) => {
6061
.convertPrecision( priceCurrency.minorUnit )
6162
.getAmount();
6263
const totalsCurrency = getCurrency( totals );
64+
65+
let lineTotal = parseInt( totals.line_total, 10 );
66+
if ( DISPLAY_CART_PRICES_INCLUDING_TAX ) {
67+
lineTotal += parseInt( totals.line_total_tax, 10 );
68+
}
6369
const totalsPrice = Dinero( {
64-
amount: parseInt( totals.line_total, 10 ),
70+
amount: lineTotal,
6571
} )
6672
.convertPrecision( totals.currency_minor_unit )
6773
.getAmount();

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { getCurrency } from '@woocommerce/price-format';
1919
import { __experimentalApplyCheckoutFilter } from '@woocommerce/blocks-checkout';
2020
import Dinero from 'dinero.js';
21+
import { DISPLAY_CART_PRICES_INCLUDING_TAX } from '@woocommerce/block-settings';
2122

2223
/**
2324
* @typedef {import('@woocommerce/type-defs/cart').CartItem} CartItem
@@ -81,6 +82,7 @@ const CartLineItemRow = ( { lineItem = {} } ) => {
8182
currency_decimal_separator: '.',
8283
currency_thousand_separator: ',',
8384
line_total: '0',
85+
line_total_tax: '0',
8486
},
8587
extensions,
8688
} = lineItem;
@@ -117,8 +119,12 @@ const CartLineItemRow = ( { lineItem = {} } ) => {
117119
);
118120
const saleAmount = saleAmountSingle.multiply( quantity );
119121
const totalsCurrency = getCurrency( totals );
122+
let lineTotal = parseInt( totals.line_total, 10 );
123+
if ( DISPLAY_CART_PRICES_INCLUDING_TAX ) {
124+
lineTotal += parseInt( totals.line_total_tax, 10 );
125+
}
120126
const totalsPrice = Dinero( {
121-
amount: parseInt( totals.line_total, 10 ),
127+
amount: lineTotal,
122128
} );
123129

124130
const firstImage = images.length ? images[ 0 ] : {};

0 commit comments

Comments
 (0)