src/Services/Pricing.php
BeforeProposed
+9−2
1111 }
1212 public static function total(Quote $quote, int $packs): array
1313 {
14 // TODO: select the tier and compute the comparable total.
15 return ['goodsCents' => 0, 'taxAddedCents' => 0, 'shippingCents' => 0, 'totalCents' => 0];
14 $price = $quote->tiers[0]['priceCents'];
15 foreach ($quote->tiers as $tier) {
16 if ($tier['minPacks'] <= $packs) $price = $tier['priceCents'];
17 }
18 $goods = $packs * $price;
19 // Round once for the complete goods line, never separately per pack.
20 $tax = $quote->taxIncluded ? 0 : intdiv($goods * $quote->taxBps + 5000, 10000);
21 return ['goodsCents' => $goods, 'taxAddedCents' => $tax,
22 'shippingCents' => $quote->shipping, 'totalCents' => $goods + $tax + $quote->shipping];
1623 }
1724}