Skip to content

Commit

Permalink
Add in personalized recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
scotchi committed Nov 21, 2010
1 parent c2a2d91 commit 52e7963
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/helpers/edgy_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_edgy_related_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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 %>
Expand Down

0 comments on commit 52e7963

Please sign in to comment.