Skip to content

Commit 576ea9b

Browse files
committed
Implementing Orders
1 parent 5102d9b commit 576ea9b

5 files changed

Lines changed: 53 additions & 18 deletions

File tree

app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<div class="container">
1212
<%= render 'layouts/header' %>
13+
<%= yield :header %>
1314
<% flash.each do |message_type, message| %>
1415
<%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
1516
<% end %>

app/views/orders/_order.html.erb

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
<h3>
2+
<%= link_to ( gravatar_for User.find_by(id:order.user_id), size: 100 ) , User.find_by(id:order.user_id) %>
23
Order ID
34
<%= order.id %>
45
, User ID
56
<%= order.user_id %></h3>
67
<p>
78
<strong>Name:</strong>
8-
<%= User.find_by(id:order.user_id).name %></p>
9-
<p>
9+
<%= User.find_by(id:order.user_id).name %>
10+
11+
,
1012
<strong>Email:</strong>
11-
<%= User.find_by(id:order.user_id).email %></p>
12-
<p>
13-
<strong>Description:</strong>
14-
<%= order.description %></p>
15-
<p>
13+
<%= User.find_by(id:order.user_id).email %>
14+
15+
,
1616
<strong>Pay_method:</strong>
1717
<%= order.pay_method %></p>
18-
<p>Line Items:
18+
<p>
19+
<strong> Description</strong>
20+
<div class="well well-sm"><%= order.description %></div>
21+
</p>
22+
<p>
23+
<h3>Total price:
24+
<%= number_to_currency(@current_cart.sub_total) %></h3>
1925
</p>
20-
<ul>
21-
<% order.line_items.each do |item| %>
22-
<li><%= item.quantity %>
26+
27+
<button type="button" class="btn btn-success" data-toggle="collapse" data-target="#<%= order.id %>">Show Items</button>
28+
<div id="<%= order.id %>" class="collapse">
29+
<ul class="users">
30+
<% @current_cart.line_items.each do |item| %>
31+
<%= item.quantity %>
2332
x
24-
<%= item.product.name %></li>
25-
<% end %>
26-
<br/>
27-
</ul>
33+
<%= render 'shared/order_product' , product:item.product%>
34+
<% end %>
35+
<br/>
36+
</ul>
37+
</div>
2838
<hr/>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<li>
2+
3+
<%= link_to product do%>
4+
<% if product.picture? %>
5+
<%= image_tag product.picture.url , size:"64x64" %>
6+
<% else %>
7+
<%= image_tag "no_image.png", size:"64x64" %>
8+
<%end%>
9+
<%end %>
10+
11+
<strong>
12+
Name :
13+
</strong>
14+
<%= product.name %>
15+
,<strong>
16+
Description :
17+
</strong>
18+
<%= product.description %>
19+
<strong>
20+
Price :
21+
</strong>
22+
<%= product.price %> $
23+
24+
</li>

app/views/shared/_product.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
<%= link_to product do%>
44
<% if product.picture? %>
5-
<%= image_tag product.picture.url %>
5+
<%= image_tag product.picture.url , size:"100x100"%>
66
<% else %>
7-
<%= image_tag "no_image.png", size:"150x150" %>
7+
<%= image_tag "no_image.png", size:"100x100" %>
88
<%end%>
99
<%end %>
1010

app/views/users/_user.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li>
2-
<%= gravatar_for user, size: 100 %>
2+
<%= link_to ( gravatar_for user, size: 100 ) , user %>
33
<%= link_to user.name, user %>
44
<p>
55
<%= pluralize(user.microposts.count, "micropost") %>

0 commit comments

Comments
 (0)