select('id') ->withPrice() ->findOrFail($id); $variantPrice = $this->cartItem($product, request('options', [])) ->total() ->convertToCurrentCurrency() ->format(); return product_price_formatted($product, function ($price) use ($product, $variantPrice) { if (! $product->hasSpecialPrice()) { return $variantPrice; } return "{$variantPrice} {$price}"; }); } private function cartItem(Product $product, array $options) { $chosenOptions = new ChosenProductOptions($product, $options); return new CartItem(new ItemCollection([ 'id' => $product->id, 'quantity' => 1, 'attributes' => [ 'product' => $product, 'options' => $chosenOptions->getEntities(), ], ])); } }