diff --git a/app/controllers/admin/variants_controller_decorator.rb b/app/controllers/admin/variants_controller_decorator.rb index cdc043e..0ecfbd4 100755 --- a/app/controllers/admin/variants_controller_decorator.rb +++ b/app/controllers/admin/variants_controller_decorator.rb @@ -5,4 +5,11 @@ def regenerate product.do_create_variants(:recreate) redirect_to :action => :index, :product_id => params[:product_id] end + + def delete_all + product = Product.find_by_permalink(params[:product_id]) + product.variants.delete_all + redirect_to :action => :index, :product_id => params[:product_id] + end + end \ No newline at end of file diff --git a/app/controllers/orders_controller_decorator.rb b/app/controllers/orders_controller_decorator.rb index 966b997..7da0557 100755 --- a/app/controllers/orders_controller_decorator.rb +++ b/app/controllers/orders_controller_decorator.rb @@ -29,7 +29,7 @@ def enhanced_option_create_before end if params[:option_values] if quantity > 0 && variant - if quantity > variant.on_hand + if Spree::Config[:track_inventory_levels] && quantity > variant.on_hand flash[:error] = t(:stock_to_small) % [variant.on_hand] else @order.add_variant(variant, quantity) diff --git a/app/views/admin/variants/index.html.erb b/app/views/admin/variants/index.html.erb index 1be3fb8..5311557 100755 --- a/app/views/admin/variants/index.html.erb +++ b/app/views/admin/variants/index.html.erb @@ -5,6 +5,13 @@ :confirm => t(:regenerate_confirm), :style => "float: right" %> +<%= button_link_to t(:delete_all), + {:action => :delete_all, :product_id => params[:product_id]}, + :method => :post, + :icon => 'exclamation', + :confirm => t(:delete_confirm), + :style => "float: right" +%> <%= render :partial => 'admin/shared/product_sub_menu' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 96c7e5e..0288fd3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -7,4 +7,6 @@ en: variant_price: Variant price regenerate: "regenerate variants" regenerate_confirm: "This will wipe out all your current variants\nAre you sure?" + delete_all: "Delete All" + delete_confirm: "Are you really sure you want to delete all current variants?"