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

Commit

Permalink
Mini-Cart: don't include shipping price
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Jun 20, 2023
1 parent d7652f3 commit dd9299f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions assets/js/blocks/mini-cart/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import { CartResponse, isBoolean } from '@woocommerce/types';
import { getSettingWithCoercion } from '@woocommerce/settings';

const getPrice = ( cartResponse: CartResponse, showIncludingTax: boolean ) => {
const currency = getCurrencyFromPriceResponse( cartResponse.totals );
const { totals } = cartResponse;
const currency = getCurrencyFromPriceResponse( totals );

return showIncludingTax
? formatPrice( cartResponse.totals.total_price, currency )
: formatPrice( cartResponse.totals.total_items, currency );
const subTotal = showIncludingTax
? parseInt( totals.total_items, 10 ) +
parseInt( totals.total_items_tax, 10 )
: parseInt( totals.total_items, 10 );

return formatPrice( subTotal, currency );
};

export const updateTotals = ( totals: [ string, number ] | undefined ) => {
Expand Down
6 changes: 4 additions & 2 deletions assets/js/blocks/mini-cart/utils/test/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const responseMock = {
ok: true,
json: async () => ( {
totals: {
total_price: '1600',
total_price: '1800',
total_items: '1400',
total_items_tax: '200',
currency_code: 'USD',
currency_symbol: '$',
currency_minor_unit: 2,
Expand All @@ -34,8 +35,9 @@ const responseMock = {
} as Response;
const localStorageMock = {
totals: {
total_price: '1600',
total_price: '1800',
total_items: '1400',
total_items_tax: '200',
currency_code: 'USD',
currency_symbol: '$',
currency_minor_unit: 2,
Expand Down

0 comments on commit dd9299f

Please sign in to comment.