Created
July 8, 2017 23:53
-
-
Save nicolasblanco/628e344a664a8d105786ef5bde5ff7b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(conn, %{"product_id" => product_id}) do | |
product = Front.get_product!(product_id) | |
conn = case conn.assigns[:current_order] do | |
nil -> | |
order = Front.create_order_with_product!(product) | |
conn |> put_session(:order_id, order.id) | |
order -> | |
Front.add_product_to_order!(order, product) | |
conn | |
end | |
redirect(conn, to: cart_path(conn, :show)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment