I am trying to make my sales app send a customer a message with all the purchased items with their prices. The purchased items are stored in the dp, each item with its quantity and price.
I have fetched all the purchased items, but I can't put the items' name and prices into a single sting - which is the message to be send to the customer.
Below is my items array object
$order = App\Order::find($id);
$items = $order->orderItems;
$item = OrderItem::where('order_id', $order->id)->first();
$message = $order->code . " confirmed. ".$order->customer->name ." ". $order->customer->vehicle_plate . " has paid KES ".$order->amount." for ".$item->quantity." ".$item->item->unit->name." of ".$item->item->name." at ".$order->updated_at->format('d/m/Y h:i a');
This message has the first item of the order. I need a single message with all order items.
getItemOrderTextwhich returns the message for a single item. You could then do something like$message .= getItemOrderText($currentItem) . '<br />'.