solidus_volume_pricing 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.hound.yml +40 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +14 -0
- data/CONTRIBUTING.md +81 -0
- data/Gemfile +13 -0
- data/Guardfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +112 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/solidus_volume_pricing.js +16 -0
- data/app/controllers/spree/admin/variants_controller_decorator.rb +32 -0
- data/app/controllers/spree/admin/volume_price_models_controller.rb +27 -0
- data/app/controllers/spree/admin/volume_prices_controller.rb +11 -0
- data/app/helpers/spree/base_helper_decorator.rb +19 -0
- data/app/models/spree/line_item_decorator.rb +27 -0
- data/app/models/spree/user_decorator.rb +10 -0
- data/app/models/spree/variant_decorator.rb +104 -0
- data/app/models/spree/volume_price.rb +35 -0
- data/app/models/spree/volume_price_model.rb +8 -0
- data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_volume_price_model_admin_menu_links.html.erb.deface +3 -0
- data/app/overrides/views_decorator.rb +13 -0
- data/app/views/spree/admin/shared/_vp_product_tab.html.erb +3 -0
- data/app/views/spree/admin/variants/_edit_fields.html.erb +33 -0
- data/app/views/spree/admin/variants/volume_prices.html.erb +39 -0
- data/app/views/spree/admin/volume_price_models/_form.html.erb +9 -0
- data/app/views/spree/admin/volume_price_models/_list.html.erb +23 -0
- data/app/views/spree/admin/volume_price_models/edit.html.erb +12 -0
- data/app/views/spree/admin/volume_price_models/index.html.erb +18 -0
- data/app/views/spree/admin/volume_price_models/new.html.erb +12 -0
- data/app/views/spree/admin/volume_prices/_edit_fields.html.erb +31 -0
- data/app/views/spree/admin/volume_prices/_volume_price_fields.html.erb +33 -0
- data/app/views/spree/products/_volume_pricing.html.erb +15 -0
- data/bin/rails +7 -0
- data/config/locales/de.yml +18 -0
- data/config/locales/en.yml +18 -0
- data/config/locales/pt.yml +18 -0
- data/config/locales/ru.yml +18 -0
- data/config/locales/sv.yml +18 -0
- data/config/locales/tr.yml +18 -0
- data/config/routes.rb +12 -0
- data/db/migrate/20081119145604_create_volume_prices.rb +16 -0
- data/db/migrate/20110203174010_change_display_name_for_volume_prices.rb +9 -0
- data/db/migrate/20111206173307_prefix_volume_pricing_table_names.rb +5 -0
- data/db/migrate/20121115043422_add_discount_type_column.rb +5 -0
- data/db/migrate/20150513200904_add_role_to_volume_price.rb +5 -0
- data/db/migrate/20150603143015_create_spree_volume_price_models.rb +18 -0
- data/lib/generators/solidus_volume_pricing/install/install_generator.rb +24 -0
- data/lib/solidus_volume_pricing.rb +6 -0
- data/lib/solidus_volume_pricing/engine.rb +42 -0
- data/lib/solidus_volume_pricing/version.rb +18 -0
- data/solidus_volume_pricing.gemspec +40 -0
- data/spec/controllers/spree/admin/variants_controller_spec.rb +27 -0
- data/spec/factories/volume_price_factory.rb +12 -0
- data/spec/helpers/base_helper_spec.rb +22 -0
- data/spec/models/spree/line_item_spec.rb +34 -0
- data/spec/models/spree/order_spec.rb +49 -0
- data/spec/models/spree/variant_spec.rb +306 -0
- data/spec/models/spree/volume_price_spec.rb +121 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/support/capybara.rb +12 -0
- data/spec/support/database_cleaner.rb +24 -0
- data/spec/support/factory_girl.rb +7 -0
- data/spec/support/spree.rb +10 -0
- metadata +337 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a603c2351c842b0e767b8bf7cb8a27043aa28e0
|
4
|
+
data.tar.gz: 88d8cef36d7438bbf0d92d2784c57b87d4da8e8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba402358ed234e73ebc686aec2a111fb173643911a9e1b7b32949ef20dc8ea1f8b95972214e622d5df0d0ae4a727506786c4cd5d222e713df1bba26a5503c309
|
7
|
+
data.tar.gz: 8e636f41d105ffe1c043b9c19cec4c829f664c4626758e2e073440b76f31fc85e719fb105e9ff736ab70670e711b470dc9952d838ecb88c2ce8e846db6c79566
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
# Too picky.
|
3
|
+
Metrics/LineLength:
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
Metrics/AbcSize:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# This should truly be on for well documented gems.
|
10
|
+
Style/Documentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
# Neatly aligned code is too swell.
|
14
|
+
Style/SingleSpaceBeforeFirstArg:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
# Don't mess with RSpec DSL.
|
18
|
+
Style/BlockDelimiters:
|
19
|
+
Exclude:
|
20
|
+
- 'spec/**/*'
|
21
|
+
|
22
|
+
# We really like the readability with newline in beginning of classes.
|
23
|
+
Style/EmptyLinesAroundBlockBody:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/EmptyLinesAroundClassBody:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# It say we should use fail over raise.
|
30
|
+
Style/SignalException:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# Use nested module/class definitions instead of compact style.
|
34
|
+
# Too high git impact to change this now.
|
35
|
+
Style/ClassAndModuleChildren:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
# Avoid contradictory style rules by enforce single quotes.
|
39
|
+
Style/StringLiterals:
|
40
|
+
EnforcedStyle: single_quotes
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.3.3
|
4
|
+
sudo: false
|
5
|
+
cache: bundler
|
6
|
+
only: master
|
7
|
+
env:
|
8
|
+
matrix:
|
9
|
+
- SOLIDUS_BRANCH=v1.0 DB=mysql
|
10
|
+
- SOLIDUS_BRANCH=v1.0 DB=postgresql
|
11
|
+
- SOLIDUS_BRANCH=v1.1 DB=mysql
|
12
|
+
- SOLIDUS_BRANCH=v1.1 DB=postgresql
|
13
|
+
- SOLIDUS_BRANCH=v1.2 DB=mysql
|
14
|
+
- SOLIDUS_BRANCH=v1.2 DB=postgresql
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Spree Reviews is an open source project and we encourage contributions. Please see the [contributors guidelines](http://spreecommerce.com/documentation/contributing_to_spree.html) for more information before contributing.
|
4
|
+
|
5
|
+
In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
|
6
|
+
|
7
|
+
Here are some ways *you* can contribute:
|
8
|
+
|
9
|
+
* by using prerelease versions
|
10
|
+
* by reporting [bugs][2]
|
11
|
+
* by suggesting new features
|
12
|
+
* by writing [translations][3]
|
13
|
+
* by writing or editing documentation
|
14
|
+
* by writing specifications
|
15
|
+
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
|
16
|
+
* by refactoring code
|
17
|
+
* by resolving [issues][2]
|
18
|
+
* by reviewing patches
|
19
|
+
|
20
|
+
---
|
21
|
+
|
22
|
+
## Filing an issue
|
23
|
+
|
24
|
+
When filing an issue on this extension, please first do these things:
|
25
|
+
|
26
|
+
* Verify you can reproduce this issue in a brand new application.
|
27
|
+
* Run through the steps to reproduce the issue again.
|
28
|
+
|
29
|
+
In the issue itself please provide:
|
30
|
+
|
31
|
+
* A comprehensive list of steps to reproduce the issue.
|
32
|
+
* What you're *expecting* to happen compared with what's *actually* happening.
|
33
|
+
* The version of Spree *and* the version of Rails.
|
34
|
+
* A list of all extensions.
|
35
|
+
* Any relevant stack traces ("Full trace" preferred)
|
36
|
+
* Your `Gemfile`
|
37
|
+
|
38
|
+
In 99% of cases, this information is enough to determine the cause and solution to the problem that is being described.
|
39
|
+
|
40
|
+
---
|
41
|
+
|
42
|
+
## Pull requests
|
43
|
+
|
44
|
+
We gladly accept pull requests to fix bugs and, in some circumstances, add new features to this extension.
|
45
|
+
|
46
|
+
Here's a quick guide:
|
47
|
+
|
48
|
+
1. Fork the repo.
|
49
|
+
|
50
|
+
2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate.
|
51
|
+
|
52
|
+
3. Create new branch then make changes and add tests for your changes. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need tests!
|
53
|
+
|
54
|
+
4. Push to your fork and submit a pull request. If the changes will apply cleanly to the latest stable branches and master branch, you will only need to submit one pull request.
|
55
|
+
|
56
|
+
At this point you're waiting on us. We may suggest some changes or improvements or alternatives.
|
57
|
+
|
58
|
+
Some things that will increase the chance that your pull request is accepted, taken straight from the Ruby on Rails guide:
|
59
|
+
|
60
|
+
* Use Rails idioms and helpers.
|
61
|
+
* Include tests that fail without your code, and pass with it.
|
62
|
+
* Update the documentation, the surrounding one, examples elsewhere, guides, whatever is affected by your contribution.
|
63
|
+
|
64
|
+
---
|
65
|
+
|
66
|
+
## TL;DR
|
67
|
+
|
68
|
+
* Fork the repo
|
69
|
+
* Clone your repo
|
70
|
+
* Run `bundle install`
|
71
|
+
* Run `bundle exec rake test_app` to create the test application in `spec/dummy`
|
72
|
+
* Make your changes
|
73
|
+
* Ensure specs pass by running `bundle exec rspec spec`
|
74
|
+
* Ensure all syntax ok by running `rubocop .`
|
75
|
+
* Submit your pull request
|
76
|
+
|
77
|
+
And in case we didn't emphasize it enough: **we love tests!**
|
78
|
+
|
79
|
+
[1]: http://www.fsf.org/licensing/essays/free-sw.html
|
80
|
+
[2]: https://github.com/solidusio-contrib/solidus_volume_pricing/issues
|
81
|
+
[3]: https://github.com/solidusio-contrib/solidus_volume_pricing/tree/master/config/locales
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
guard 'rspec', cmd: 'bundle exec rspec' do
|
2
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
3
|
+
watch('config/routes.rb') { 'spec/controllers' }
|
4
|
+
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
|
5
|
+
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
|
6
|
+
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
|
8
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
|
9
|
+
end
|
data/LICENSE.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2009-2015 Spree Commerce and contributors.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# Volume Pricing
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/solidusio-contrib/solidus_volume_pricing.svg?branch=3-0-stable)](https://travis-ci.org/solidusio-contrib/solidus_volume_pricing)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/solidusio-contrib/solidus_volume_pricing/badges/gpa.svg)](https://codeclimate.com/github/solidusio-contrib/solidus_volume_pricing)
|
5
|
+
|
6
|
+
Volume Pricing is an extension to Solidus that uses predefined ranges of quantities to determine the price for a particular product variant. For instance, this allows you to set a price for quantities between 1-10, another price for quantities between (10-100) and another for quantities of 100 or more. If no volume price is defined for a variant, then the standard price is used.
|
7
|
+
|
8
|
+
Each VolumePrice contains the following values:
|
9
|
+
|
10
|
+
1. **Variant:** Each VolumePrice is associated with a _Variant_, which is used to link products to particular prices.
|
11
|
+
1. **Name:** The human readable representation of the quantity range (Ex. 10-100). (Optional)
|
12
|
+
1. **Discount Type** The type of discount to apply. **Price:** sets price to the amount specified. **Dollar:** subtracts specified amount from the Variant price. **Percent:** subtracts the specified amounts percentage from the Variant price.
|
13
|
+
1. **Range:** The quantity range for which the price is valid (See Below for Examples of Valid Ranges.)
|
14
|
+
1. **Amount:** The price of the product if the line item quantity falls within the specified range.
|
15
|
+
1. **Position:** Integer value for `acts_as_list` (Helps keep the volume prices in a defined order.)
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
## Install
|
20
|
+
|
21
|
+
The extension contains a rails generator that will add the necessary migrations and give you the option to run the migrations, or run them later, perhaps after installing other extensions. Once you have bundled the extension, run the install generator and its ready to use.
|
22
|
+
|
23
|
+
rails generate solidus_volume_pricing:install
|
24
|
+
|
25
|
+
Easily add volume pricing display to your product page:
|
26
|
+
|
27
|
+
<%= render partial: 'spree/products/volume_pricing', locals: { product: @product } %>
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
## Ranges
|
32
|
+
|
33
|
+
Ranges are expressed as Strings and are similar to the format of a Range object in Ruby. The lower number of the range is always inclusive. If the range is defined with '..' then it also includes the upper end of the range. If the range is defined with '...' then the upper end of the range is not inclusive.
|
34
|
+
|
35
|
+
Ranges can also be defined as "open ended." Open ended ranges are defined with an integer followed by a '+' character. These ranges are inclusive of the integer and any value higher then the integer.
|
36
|
+
|
37
|
+
All ranges need to be expressed as Strings and can include or exclude parentheses. "(1..10)" and "1..10" are considered to be a valid range.
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
## Examples
|
42
|
+
|
43
|
+
Consider the following examples of volume prices:
|
44
|
+
|
45
|
+
Variant Name Range Amount Position
|
46
|
+
-------------------------------------------------------------------------------
|
47
|
+
Rails T-Shirt 1-5 (1..5) 19.99 1
|
48
|
+
Rails T-Shirt 6-9 (6...10) 18.99 2
|
49
|
+
Rails T-Shirt 10 or more (10+) 17.99 3
|
50
|
+
|
51
|
+
### Example 1
|
52
|
+
|
53
|
+
Cart Contents:
|
54
|
+
|
55
|
+
Product Quantity Price Total
|
56
|
+
----------------------------------------------------------------
|
57
|
+
Rails T-Shirt 1 19.99 19.99
|
58
|
+
|
59
|
+
### Example 2
|
60
|
+
|
61
|
+
Cart Contents:
|
62
|
+
|
63
|
+
Product Quantity Price Total
|
64
|
+
----------------------------------------------------------------
|
65
|
+
Rails T-Shirt 5 19.99 99.95
|
66
|
+
|
67
|
+
### Example 3
|
68
|
+
|
69
|
+
Cart Contents:
|
70
|
+
|
71
|
+
Product Quantity Price Total
|
72
|
+
----------------------------------------------------------------
|
73
|
+
Rails T-Shirt 6 18.99 113.94
|
74
|
+
|
75
|
+
### Example 4
|
76
|
+
|
77
|
+
Cart Contents:
|
78
|
+
|
79
|
+
Product Quantity Price Total
|
80
|
+
----------------------------------------------------------------
|
81
|
+
Rails T-Shirt 10 17.99 179.90
|
82
|
+
|
83
|
+
### Example 5
|
84
|
+
|
85
|
+
Cart Contents:
|
86
|
+
|
87
|
+
Product Quantity Price Total
|
88
|
+
----------------------------------------------------------------
|
89
|
+
Rails T-Shirt 20 17.99 359.80
|
90
|
+
|
91
|
+
---
|
92
|
+
|
93
|
+
## Additional Notes
|
94
|
+
|
95
|
+
* The volume price is applied based on the total quantity ordered for a particular variant. It does not apply different prices for the portion of the quantity that falls within a particular range. Only the one price is used (although this would be an interesting configurable option if someone wanted to write a patch.)
|
96
|
+
|
97
|
+
---
|
98
|
+
|
99
|
+
## Contributing
|
100
|
+
|
101
|
+
See corresponding [contributing guidelines][1].
|
102
|
+
|
103
|
+
---
|
104
|
+
|
105
|
+
## License
|
106
|
+
|
107
|
+
Copyright (c) 2009-2015 [Spree Commerce][2] and [contributors][3], released under the [New BSD License][4]
|
108
|
+
|
109
|
+
[1]: https://github.com/solidusio-contrib/solidus_volume_pricing/blob/master/CONTRIBUTING.md
|
110
|
+
[2]: https://github.com/spree
|
111
|
+
[3]: https://github.com/solidusio-contrib/solidus_volume_pricing/graphs/contributors
|
112
|
+
[4]: https://github.com/solidusio-contrib/solidus_volume_pricing/blob/master/LICENSE.md
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'spree/testing_support/extension_rake'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
task :default do
|
10
|
+
if Dir["spec/dummy"].empty?
|
11
|
+
Rake::Task[:test_app].invoke
|
12
|
+
Dir.chdir("../../")
|
13
|
+
end
|
14
|
+
Rake::Task[:spec].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generates a dummy app for testing'
|
18
|
+
task :test_app do
|
19
|
+
ENV['LIB_NAME'] = 'solidus_volume_pricing'
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//= require spree/backend
|
2
|
+
|
3
|
+
// spree's version only handles 'input', not 'select', and this breaks solidus_volume_pricing
|
4
|
+
|
5
|
+
$(function () {
|
6
|
+
$('#add_volume_price').click( function() {
|
7
|
+
var target = $(this).data("target"),
|
8
|
+
new_table_row = $(target + ' tr:visible:first');
|
9
|
+
new_table_row.find('div.select2').remove();
|
10
|
+
$('select.select2').select2({
|
11
|
+
allowClear: true,
|
12
|
+
dropdownAutoWidth: true
|
13
|
+
});
|
14
|
+
});
|
15
|
+
|
16
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Spree::Admin::VariantsController.class_eval do
|
2
|
+
|
3
|
+
def edit
|
4
|
+
@variant.volume_prices.build if @variant.volume_prices.empty?
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def volume_prices
|
9
|
+
@product = @variant.product
|
10
|
+
@variant.volume_prices.build if @variant.volume_prices.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# this loads the variant for the master variant volume price editing
|
16
|
+
def load_resource_instance
|
17
|
+
parent
|
18
|
+
|
19
|
+
if new_actions.include?(params[:action].to_sym)
|
20
|
+
build_resource
|
21
|
+
elsif params[:id]
|
22
|
+
Spree::Variant.find(params[:id])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def location_after_save
|
27
|
+
if @product.master.id == @variant.id && params[:variant].key?(:volume_prices_attributes)
|
28
|
+
return volume_prices_admin_product_variant_url(@product, @variant)
|
29
|
+
end
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class VolumePriceModelsController < ResourceController
|
4
|
+
|
5
|
+
before_action :load_volume_prices, only: [:new, :edit]
|
6
|
+
respond_to :json, only: [:get_children]
|
7
|
+
|
8
|
+
def get_children
|
9
|
+
@volume_prices = VolumePrice.find(params[:parent_id]).children
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def location_after_save
|
15
|
+
if @volume_price_model.created_at == @volume_price_model.updated_at
|
16
|
+
edit_admin_volume_price_model_url(@volume_price_model)
|
17
|
+
else
|
18
|
+
admin_volume_price_models_url
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_volume_prices
|
23
|
+
@volume_price_model.volume_prices.build if @volume_price_model.volume_prices.empty?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|