Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add in personalized recommendations

  • Loading branch information...
commit 52e79635a9c414dc7adf8012ef0061392d86cfc5 1 parent c2a2d91
@scotchi scotchi authored
View
7 app/helpers/edgy_helper.rb
@@ -5,11 +5,15 @@ def edgy_related(options = {})
Product.edgy_related(Set.new(@order.line_items.map { |i| i.product }), options)
elsif @product
@product.edgy_related(options)
+ elsif current_user
+ current_user.edgy_recommended(options)
else
[]
end
end
+ alias :edgy_recommended :edgy_related
+
def edgy_related_table(orientation = :horizontal, options = {})
render 'shared/edgy_related_table', :orientation => orientation, :options => options
end
@@ -19,6 +23,9 @@ def edgy_message
"Customers who bought this product also bought:"
elsif @order
"Customers who bought these products also bought:"
+ elsif current_user
+ address = current_user.bill_address
+ "Welcome back#{address ? (', ' + address.firstname) : ''}. Here are our recommendations for you:"
else
"You might also like:"
end
View
4 app/views/shared/_edgy_related_table.html.erb
@@ -16,7 +16,7 @@
<% edgy_related.each do |related_product| %>
<td class="edgy-label">
<%=h link_to related_product.name, related_product %><br />
- <span class="price"><%=h number_to_currency related_product.price %></span>
+ <span class="price"><%=h product_price(related_product) %></span>
</td>
<% end %>
</tr>
@@ -28,7 +28,7 @@
</td>
<td class="edgy-label">
<%=h link_to related_product.name, related_product %><br />
- <span class="price"><%=h number_to_currency related_product.price %></span>
+ <span class="price"><%=h product_price(related_product) %></span>
</td>
</tr>
<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.