I’m making a simple webshop to get to know the phoenix framework (umbrella project).
I have a many-to-many relation between orders and products.
In the association table I have the columns ‘order_id’, ‘product_id’ and ‘quantity’.
I want to display the quantity next to each item in the shopping cart, but I just can’t figure out how to do it.
In my order_controller I have:
def cart(conn, _params) do
user = Guardian.Plug.current_resource(conn)
order = OrderContext.get_currenct_order(user)
render(conn, "cart.html", order: order)
end
In cart.html.heex I can loop over order.products and access attributes of product just fine (product.name, product.price, …).