All files / app/order getItemsCount.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17    9x 37x 37x 37x 37x   37x       79x   37x    
import { LineItemMap } from '@bigcommerce/checkout-sdk';
 
export default function getItemsCount({
    physicalItems,
    digitalItems,
    giftCertificates,
    customItems,
}: LineItemMap): number {
    const totalItemsCount = [
        ...physicalItems,
        ...digitalItems,
        ...(customItems || []),
    ].reduce((total, item) => total += item.quantity, 0);
 
    return totalItemsCount + giftCertificates.length;
}