Skip to content

Commit 5494a24

Browse files
[frontend] fix item calculation and shipping (#2684)
1 parent 5d6662e commit 5494a24

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ the release.
1818
* [chore] Upgrade OpenFeature and add fix deprecation warnings for dependency
1919
injection
2020
([#2644](https://github.com/open-telemetry/opentelemetry-demo/pull/2644))
21+
* [frontend] fix item calculation and shipping
22+
([#2684](https://github.com/open-telemetry/opentelemetry-demo/pull/2684))
2123

2224
## 2.1.3
2325

src/frontend/pages/cart/checkout/[orderId]/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const Checkout: NextPage = () => {
2121
const { orderId, items = [], shippingAddress, shippingCost = { units: 0, currencyCode: 'USD', nanos: 0 } } = JSON.parse((query.order || '{}') as string) as IProductCheckout;
2222

2323
const orderTotal = useMemo<Money>(() => {
24-
const itemsTotal = items.reduce((acc, { cost = { units: 0, nanos: 0, currencyCode: 'USD' } }) => {
24+
const itemsTotal = items.reduce((acc, { item, cost = { units: 0, nanos: 0, currencyCode: 'USD' } }) => {
2525
return {
26-
units: acc.units + (cost.units || 0),
27-
nanos: acc.nanos + (cost.nanos || 0),
26+
units: acc.units + (cost.units || 0) * item.quantity,
27+
nanos: acc.nanos + (cost.nanos || 0) * item.quantity,
2828
currencyCode: cost.currencyCode || 'USD',
2929
};
3030
}, { units: 0, nanos: 0, currencyCode: 'USD' });

src/quote/app/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function calculateQuote($jsonObject): float
2626
throw new \InvalidArgumentException('numberOfItems not provided');
2727
}
2828
$numberOfItems = intval($jsonObject['numberOfItems']);
29-
$costPerItem = rand(400, 1000)/10;
29+
$costPerItem = 8.99;
3030
$quote = round($costPerItem * $numberOfItems, 2);
3131

3232
$childSpan->setAttribute('app.quote.items.count', $numberOfItems);

0 commit comments

Comments
 (0)