Skip to content

Commit

Permalink
Wholesale price displays on product admin index
Browse files Browse the repository at this point in the history
  • Loading branch information
mlambie committed Oct 15, 2009
1 parent 0cda4e0 commit cbef3f0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
76 changes: 76 additions & 0 deletions app/views/admin/products/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<% content_for :head do %>
<%= calendar_date_select_includes %>
<% end %>
<% render :partial => 'admin/shared/product_sub_menu' %>

<div class='toolbar'>
<ul class='actions'>
<li id="new_ot_link">
<%= button_link_to_remote t("new_product"),
{:url => new_object_url,
:method => :get,
:update => "new-product",
:before => "Element.hide('new_ot_link');Element.show('busy_indicator')",
:complete => "Element.hide('busy_indicator')"}, :icon => 'add' %>
</li>
</ul>
<br class='clear' />
</div>

<h1><%= "#{t("actions.listing")} #{t("products")}" %></h1>

<%= image_tag "spinner.gif", :plugin=>"spree", :style => "display:none", :id => 'busy_indicator' %>
<div id="new-product"></div>

<table class="index">
<tr>
<th><%= t("sku") %></th>
<th><%= order @search, :by => :name, :as => t("name") %></th>
<th><%= order @search, :by => :price, :as => t("master_price") %></th>
<th><%= order @search, :by => :wholesale_price, :as => t("wholesale_price") %></th>
<th>&nbsp;</th>
</tr>
<% @collection.each do |product| %>
<tr <%= 'style="color:red;"' unless product.deleted_at.nil? %> id="<%= dom_id product %>">
<td><%= product.sku %></td>
<td><%= product.name %></td>
<td><%= product.price %></td>
<td><%= product.wholesale_price %></td>
<td class="actions">
<%= link_to_edit product if product.deleted_at.nil? %>
&nbsp;
<%= link_to_delete product if product.deleted_at.nil? %>
</td>
</tr>
<% end %>
</table>
<%= will_paginate (:prev => "&#171; #{t('previous')}", :next => "#{t('next')} &#187;") %>
<% content_for :sidebar do %>
<% form_for @search do |f| %>
<div class="box">
<h3><%= t(:search) %></h3>

<p>
<label><%= t("name") %></label><br />
<%= f.text_field :name_contains, :size => 15 %>
</p>

<p>
<label><%= t("sku") %></label><br />
<%= f.text_field :variants_sku_contains, :size => 15 %>
</p>
<p>
<label><%= t("show_deleted") %></label><br />
<%= f.check_box :deleted_at_not_null, {}, "1", "" %>
</p>
<p class="form-buttons">
<%= button t("search") %>
</p>
</div>
<% end %>
<% end %>

5 changes: 5 additions & 0 deletions wholesale_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def activate
# add_extension_admin_tab [ :yourextension ]
# end
#end

# Reopen the Product class and delegate wholesale_price (first variant)
Product.class_eval do
delegate_belongs_to :master, :wholesale_price
end

# make your helper avaliable in all views
# Spree::BaseController.class_eval do
Expand Down

0 comments on commit cbef3f0

Please sign in to comment.