forked from spree-contrib/spree_volume_pricing
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chris Boertien <chris.boertien@bz-labs.com>
- Loading branch information
1 parent
8701aa4
commit 6fdcdda
Showing
3 changed files
with
17 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ end | |
task :test_app do | ||
ENV['LIB_NAME'] = 'spree_volume_pricing' | ||
Rake::Task['common:test_app'].invoke | ||
end | ||
end |
19 changes: 10 additions & 9 deletions
19
app/controllers/spree/admin/variants_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
Spree::Admin::VariantsController.class_eval do | ||
# this loads the variant for the master variant volume price editing | ||
update.before :before_update | ||
|
||
respond_override :update => {:html => { | ||
:success => lambda { redirect_to(@variant.is_master ? volume_prices_admin_product_variant_url(@variant.product, @variant) : collection_url) }, | ||
:failure => lambda { redirect_to(@variant.is_master ? volume_prices_admin_product_variant_url(@variant.product, @variant) : collection_url) } } } | ||
|
||
def load_resource_instance | ||
parent | ||
|
||
if new_actions.include?(params[:action].to_sym) | ||
build_resource | ||
elsif params[:id] | ||
Spree::Variant.find(params[:id]) | ||
Variant.find(params[:id]) | ||
end | ||
end | ||
|
||
def volume_prices | ||
@product = @variant.product | ||
@variant.volume_prices.build | ||
end | ||
|
||
def location_after_save | ||
if @product.master.id == @variant.id and params[:variant].has_key? :volume_prices_attributes | ||
return volume_prices_admin_product_variant_url(@product, @variant) | ||
end | ||
|
||
super | ||
protected | ||
def before_update | ||
params[:variant][:volume_prices_attributes] ||= {} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters