diff --git a/src/Factory/Cart/CartItemViewFactory.php b/src/Factory/Cart/CartItemViewFactory.php index 2d80a3b53..8d262585a 100644 --- a/src/Factory/Cart/CartItemViewFactory.php +++ b/src/Factory/Cart/CartItemViewFactory.php @@ -39,7 +39,7 @@ public function create(OrderItemInterface $item, ChannelInterface $channel, stri $itemView->id = $item->getId(); $itemView->quantity = $item->getQuantity(); - $itemView->total = $item->getTotal(); + $itemView->total = $item->getSubtotal(); $itemView->product = $this->productViewFactory->create($item->getProduct(), $channel, $locale); $itemView->product->variants = [$this->productVariantViewFactory->create($item->getVariant(), $channel, $locale)]; diff --git a/src/Factory/Cart/TotalViewFactory.php b/src/Factory/Cart/TotalViewFactory.php index dc2866406..f3fecc41f 100644 --- a/src/Factory/Cart/TotalViewFactory.php +++ b/src/Factory/Cart/TotalViewFactory.php @@ -25,10 +25,21 @@ public function create(OrderInterface $cart): TotalsView $totalsView->promotion = $cart->getOrderPromotionTotal(); $totalsView->total = $cart->getTotal(); - $totalsView->items = $cart->getItemsTotal(); + $totalsView->items = $this->getSubtotal($cart); $totalsView->shipping = $cart->getShippingTotal(); $totalsView->taxes = $cart->getTaxTotal(); return $totalsView; } + + private function getSubtotal(OrderInterface $order): int + { + return array_reduce( + $order->getItems()->toArray(), + static function (int $subtotal, OrderItemInterface $item) { + return $subtotal + $item->getSubtotal(); + }, + 0 + ); + } }