solidus_volume_pricing 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -4
- data/.rubocop_todo.yml +126 -0
- data/CHANGELOG.md +57 -0
- data/Gemfile +18 -4
- data/Guardfile +3 -1
- data/README.md +53 -48
- data/Rakefile +2 -0
- data/app/assets/javascripts/spree/backend/solidus_volume_pricing.js +1 -15
- data/app/controllers/spree/admin/volume_price_models_controller.rb +2 -1
- data/app/controllers/spree/admin/volume_prices_controller.rb +3 -1
- data/app/decorators/controllers/solidus_volume_pricing/spree/admin/variants_controller_decorator.rb +42 -0
- data/app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb +31 -0
- data/app/decorators/models/solidus_volume_pricing/spree/line_item_decorator.rb +18 -0
- data/app/decorators/models/solidus_volume_pricing/spree/user_decorator.rb +17 -0
- data/app/decorators/models/solidus_volume_pricing/spree/variant_decorator.rb +21 -0
- data/app/models/solidus_volume_pricing/price_display.rb +47 -0
- data/app/models/solidus_volume_pricing/pricer.rb +95 -0
- data/app/models/solidus_volume_pricing/pricing_options.rb +20 -0
- data/app/models/spree/volume_price.rb +43 -26
- data/app/models/spree/volume_price_model.rb +6 -4
- data/app/overrides/spree/admin/shared/_settings_sub_menu/add_volume_price_model_admin_menu_links.html.erb.deface +5 -0
- data/app/overrides/views_decorator.rb +2 -0
- data/app/views/spree/admin/shared/_vp_product_tab.html.erb +2 -2
- data/app/views/spree/admin/variants/_edit_fields.html.erb +5 -32
- data/app/views/spree/admin/variants/volume_prices.html.erb +9 -36
- data/app/views/spree/admin/volume_price_models/_form.html.erb +6 -2
- data/app/views/spree/admin/volume_price_models/_list.html.erb +8 -4
- data/app/views/spree/admin/volume_price_models/_select.html.erb +17 -0
- data/app/views/spree/admin/volume_price_models/edit.html.erb +7 -6
- data/app/views/spree/admin/volume_price_models/index.html.erb +7 -5
- data/app/views/spree/admin/volume_price_models/new.html.erb +5 -5
- data/app/views/spree/admin/volume_prices/_table.html.erb +26 -0
- data/app/views/spree/admin/volume_prices/_volume_price_fields.html.erb +6 -6
- data/app/views/spree/products/_volume_pricing.html.erb +8 -8
- data/bin/rails +3 -2
- data/config/locales/de.yml +17 -3
- data/config/locales/en.yml +21 -2
- data/config/locales/pt.yml +6 -2
- data/config/locales/ru.yml +6 -2
- data/config/locales/sv.yml +6 -2
- data/config/locales/tr.yml +6 -2
- data/config/routes.rb +3 -1
- data/db/migrate/20081119145604_create_volume_prices.rb +3 -1
- data/db/migrate/20110203174010_change_display_name_for_volume_prices.rb +3 -1
- data/db/migrate/20111206173307_prefix_volume_pricing_table_names.rb +3 -1
- data/db/migrate/20121115043422_add_discount_type_column.rb +3 -1
- data/db/migrate/20150513200904_add_role_to_volume_price.rb +3 -1
- data/db/migrate/20150603143015_create_spree_volume_price_models.rb +3 -1
- data/lib/generators/solidus_volume_pricing/install/install_generator.rb +3 -5
- data/lib/solidus_volume_pricing.rb +5 -1
- data/lib/solidus_volume_pricing/engine.rb +5 -22
- data/lib/solidus_volume_pricing/range_from_string.rb +36 -0
- data/lib/solidus_volume_pricing/version.rb +5 -3
- data/solidus_volume_pricing.gemspec +6 -14
- data/spec/controllers/spree/admin/variants_controller_spec.rb +18 -15
- data/spec/factories/volume_price_factory.rb +7 -5
- data/spec/features/manage_volume_price_models_feature_spec.rb +5 -3
- data/spec/features/manage_volume_prices_feature_spec.rb +6 -4
- data/spec/helpers/base_helper_spec.rb +3 -1
- data/spec/lib/solidus_volume_pricing/range_from_string_spec.rb +61 -0
- data/spec/models/solidus_volume_pricing/pricer_spec.rb +673 -0
- data/spec/models/solidus_volume_pricing/pricing_options_spec.rb +57 -0
- data/spec/models/spree/line_item_spec.rb +24 -21
- data/spec/models/spree/order_spec.rb +4 -2
- data/spec/models/spree/variant_spec.rb +3 -303
- data/spec/models/spree/volume_price_spec.rb +153 -49
- data/spec/spec_helper.rb +5 -38
- data/spec/support/shoulda.rb +11 -0
- metadata +37 -173
- data/.hound.yml +0 -40
- data/.travis.yml +0 -12
- data/CONTRIBUTING.md +0 -81
- data/app/controllers/spree/admin/variants_controller_decorator.rb +0 -32
- data/app/helpers/spree/base_helper_decorator.rb +0 -19
- data/app/models/spree/line_item_decorator.rb +0 -13
- data/app/models/spree/user_decorator.rb +0 -10
- data/app/models/spree/variant_decorator.rb +0 -104
- data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_volume_price_model_admin_menu_links.html.erb.deface +0 -3
- data/app/views/spree/admin/volume_prices/_edit_fields.html.erb +0 -31
- data/spec/support/capybara.rb +0 -12
- data/spec/support/database_cleaner.rb +0 -21
- data/spec/support/factory_girl.rb +0 -7
- data/spec/support/spree.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '08283fd45b610c42b6d37427a84de81b106b0a2dab729a45b3e8305148019c5f'
|
4
|
+
data.tar.gz: 137f128fb1d1e761b371bab30b4a3277311d4d97b201f313197ed7f1775ead8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf43af51a07a4fcd12129e241c9b512472725dc884ea3d487f23152e8df135dcf82bff22753116fe45df983a231667feab640db82929b260058e55857ed71af5
|
7
|
+
data.tar.gz: e2f055f385c8869c4e0407da0bc3f01946c1eb210c124704a49627b34b6b1762e5f0d9d5be244509385269dc0118fcbe7a35307b26580a36b8d6d948aeb9b9dc
|
@@ -0,0 +1,35 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
# Always take the latest version of the orb, this allows us to
|
5
|
+
# run specs against Solidus supported versions only without the need
|
6
|
+
# to change this configuration every time a Solidus version is released
|
7
|
+
# or goes EOL.
|
8
|
+
solidusio_extensions: solidusio/extensions@volatile
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
run-specs-with-postgres:
|
12
|
+
executor: solidusio_extensions/postgres
|
13
|
+
steps:
|
14
|
+
- solidusio_extensions/run-tests
|
15
|
+
run-specs-with-mysql:
|
16
|
+
executor: solidusio_extensions/mysql
|
17
|
+
steps:
|
18
|
+
- solidusio_extensions/run-tests
|
19
|
+
|
20
|
+
workflows:
|
21
|
+
"Run specs on supported Solidus versions":
|
22
|
+
jobs:
|
23
|
+
- run-specs-with-postgres
|
24
|
+
- run-specs-with-mysql
|
25
|
+
"Weekly run specs against master":
|
26
|
+
triggers:
|
27
|
+
- schedule:
|
28
|
+
cron: "0 0 * * 4" # every Thursday
|
29
|
+
filters:
|
30
|
+
branches:
|
31
|
+
only:
|
32
|
+
- master
|
33
|
+
jobs:
|
34
|
+
- run-specs-with-postgres
|
35
|
+
- run-specs-with-mysql
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
require:
|
4
|
+
- solidus_extension_dev_tools/rubocop
|
5
|
+
|
6
|
+
inherit_gem:
|
7
|
+
solidus_extension_dev_tools: .rubocop.extension.yml
|
3
8
|
|
4
9
|
AllCops:
|
5
10
|
Exclude:
|
6
11
|
- spec/dummy/**/*
|
7
|
-
-
|
8
|
-
- Guardfile
|
12
|
+
- vendor/**/*
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-11-23 17:04:33 +0100 using RuboCop version 0.76.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemspec,
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'solidus_volume_pricing.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 2
|
17
|
+
Lint/InterpolationCheck:
|
18
|
+
Exclude:
|
19
|
+
- 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'
|
20
|
+
|
21
|
+
# Offense count: 21
|
22
|
+
# Cop supports --auto-correct.
|
23
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
24
|
+
# URISchemes: http, https
|
25
|
+
Metrics/LineLength:
|
26
|
+
Max: 160
|
27
|
+
|
28
|
+
# Offense count: 43
|
29
|
+
# Configuration parameters: Prefixes.
|
30
|
+
# Prefixes: when, with, without
|
31
|
+
RSpec/ContextWording:
|
32
|
+
Exclude:
|
33
|
+
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
|
34
|
+
- 'spec/helpers/base_helper_spec.rb'
|
35
|
+
- 'spec/models/solidus_volume_pricing/pricer_spec.rb'
|
36
|
+
- 'spec/models/spree/order_spec.rb'
|
37
|
+
- 'spec/models/spree/volume_price_spec.rb'
|
38
|
+
|
39
|
+
# Offense count: 2
|
40
|
+
RSpec/DescribeClass:
|
41
|
+
Exclude:
|
42
|
+
- 'spec/features/manage_volume_price_models_feature_spec.rb'
|
43
|
+
- 'spec/features/manage_volume_prices_feature_spec.rb'
|
44
|
+
|
45
|
+
# Offense count: 1
|
46
|
+
# Configuration parameters: CustomTransform, IgnoreMethods.
|
47
|
+
RSpec/FilePath:
|
48
|
+
Exclude:
|
49
|
+
- 'spec/helpers/base_helper_spec.rb'
|
50
|
+
|
51
|
+
# Offense count: 29
|
52
|
+
# Configuration parameters: AssignmentOnly.
|
53
|
+
RSpec/InstanceVariable:
|
54
|
+
Exclude:
|
55
|
+
- 'spec/helpers/base_helper_spec.rb'
|
56
|
+
- 'spec/models/spree/order_spec.rb'
|
57
|
+
|
58
|
+
# Offense count: 5
|
59
|
+
# Configuration parameters: AggregateFailuresByDefault.
|
60
|
+
RSpec/MultipleExpectations:
|
61
|
+
Max: 3
|
62
|
+
|
63
|
+
# Offense count: 58
|
64
|
+
# Configuration parameters: IgnoreSharedExamples.
|
65
|
+
RSpec/NamedSubject:
|
66
|
+
Exclude:
|
67
|
+
- 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'
|
68
|
+
- 'spec/models/solidus_volume_pricing/pricer_spec.rb'
|
69
|
+
- 'spec/models/solidus_volume_pricing/pricing_options_spec.rb'
|
70
|
+
- 'spec/models/spree/volume_price_spec.rb'
|
71
|
+
|
72
|
+
# Offense count: 74
|
73
|
+
RSpec/NestedGroups:
|
74
|
+
Max: 7
|
75
|
+
|
76
|
+
# Offense count: 1
|
77
|
+
# Configuration parameters: Include.
|
78
|
+
# Include: db/migrate/*.rb
|
79
|
+
Rails/CreateTableWithTimestamps:
|
80
|
+
Exclude:
|
81
|
+
- 'db/migrate/20150603143015_create_spree_volume_price_models.rb'
|
82
|
+
|
83
|
+
# Offense count: 1
|
84
|
+
# Configuration parameters: Include.
|
85
|
+
# Include: app/models/**/*.rb
|
86
|
+
Rails/HasManyOrHasOneDependent:
|
87
|
+
Exclude:
|
88
|
+
- 'app/models/spree/volume_price_model.rb'
|
89
|
+
|
90
|
+
# Offense count: 2
|
91
|
+
# Configuration parameters: Include.
|
92
|
+
# Include: app/models/**/*.rb
|
93
|
+
Rails/InverseOf:
|
94
|
+
Exclude:
|
95
|
+
- 'app/models/spree/volume_price.rb'
|
96
|
+
- 'app/models/spree/volume_price_model.rb'
|
97
|
+
|
98
|
+
# Offense count: 1
|
99
|
+
# Configuration parameters: Include.
|
100
|
+
# Include: app/controllers/**/*.rb
|
101
|
+
Rails/LexicallyScopedActionFilter:
|
102
|
+
Exclude:
|
103
|
+
- 'app/controllers/spree/admin/volume_price_models_controller.rb'
|
104
|
+
|
105
|
+
# Offense count: 1
|
106
|
+
# Configuration parameters: Include.
|
107
|
+
# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
|
108
|
+
Rails/Output:
|
109
|
+
Exclude:
|
110
|
+
- 'lib/generators/solidus_volume_pricing/install/install_generator.rb'
|
111
|
+
|
112
|
+
# Offense count: 2
|
113
|
+
# Configuration parameters: Blacklist, Whitelist.
|
114
|
+
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
|
115
|
+
Rails/SkipsModelValidations:
|
116
|
+
Exclude:
|
117
|
+
- 'spec/models/spree/volume_price_spec.rb'
|
118
|
+
|
119
|
+
# Offense count: 2
|
120
|
+
# Cop supports --auto-correct.
|
121
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
122
|
+
# SupportedStyles: nested, compact
|
123
|
+
Style/ClassAndModuleChildren:
|
124
|
+
Exclude:
|
125
|
+
- 'app/models/spree/volume_price.rb'
|
126
|
+
- 'app/models/spree/volume_price_model.rb'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v1.0.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.0.0) (2019-11-23)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.2.1...v1.0.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Replace `I18n.t` with `t` in views [\#22](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/22)
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- can we create packs of product by this ? [\#13](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/13)
|
14
|
+
- Rails v 5.0.1 [\#8](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/8)
|
15
|
+
|
16
|
+
**Merged pull requests:**
|
17
|
+
|
18
|
+
- Replace I18n.t with t in views [\#34](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/34) ([aldesantis](https://github.com/aldesantis))
|
19
|
+
- Reformat readme [\#33](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/33) ([aldesantis](https://github.com/aldesantis))
|
20
|
+
- Adopt solidus\_extension\_dev\_tools [\#32](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/32) ([aldesantis](https://github.com/aldesantis))
|
21
|
+
- Switch to sassc/rails [\#30](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/30) ([pelargir](https://github.com/pelargir))
|
22
|
+
- Update pg requirement from ~\> 0.21 to ~\> 1.1 [\#27](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/27) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
23
|
+
- Update coffee-rails requirement from ~\> 4.0 to ~\> 5.0 [\#26](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/26) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
24
|
+
- Adopt CircleCI instead of Travis [\#23](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/23) ([aldesantis](https://github.com/aldesantis))
|
25
|
+
- Solidus 2.4 UI updates [\#21](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/21) ([tvdeyen](https://github.com/tvdeyen))
|
26
|
+
- Test suite maintenance [\#20](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/20) ([aitbw](https://github.com/aitbw))
|
27
|
+
- Remove 2.2 from CI \(EOL\) [\#19](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/19) ([jacobherrington](https://github.com/jacobherrington))
|
28
|
+
- Remove versions past EOL from .travis.yml [\#17](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/17) ([jacobherrington](https://github.com/jacobherrington))
|
29
|
+
- Add Solidus 2.1-2.7 to .travis.yml [\#16](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/16) ([jacobherrington](https://github.com/jacobherrington))
|
30
|
+
- Remove deprecated icon option from button [\#12](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/12) ([pelargir](https://github.com/pelargir))
|
31
|
+
- V2.1 [\#11](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/11) ([seand7565](https://github.com/seand7565))
|
32
|
+
- Role fix [\#9](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/9) ([Senjai](https://github.com/Senjai))
|
33
|
+
- 1.0 fixes [\#7](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/7) ([tvdeyen](https://github.com/tvdeyen))
|
34
|
+
- Add pricers to calculate volume prices [\#4](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/4) ([tvdeyen](https://github.com/tvdeyen))
|
35
|
+
- Remove String monkey patch [\#3](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/3) ([tvdeyen](https://github.com/tvdeyen))
|
36
|
+
|
37
|
+
## [v0.2.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.2.1) (2017-01-20)
|
38
|
+
|
39
|
+
[Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.1.1...v0.2.1)
|
40
|
+
|
41
|
+
**Merged pull requests:**
|
42
|
+
|
43
|
+
- 0.2 fixes [\#6](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/6) ([tvdeyen](https://github.com/tvdeyen))
|
44
|
+
- Solidus 1.3 [\#2](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/2) ([tvdeyen](https://github.com/tvdeyen))
|
45
|
+
|
46
|
+
## [v0.1.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.1.1) (2017-01-20)
|
47
|
+
|
48
|
+
[Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/9bcf78426749d2d73878c6c7c8eb3bf0e5747ada...v0.1.1)
|
49
|
+
|
50
|
+
**Merged pull requests:**
|
51
|
+
|
52
|
+
- 0.1 fixes [\#5](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/5) ([tvdeyen](https://github.com/tvdeyen))
|
53
|
+
- Rename to solidus [\#1](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/1) ([tvdeyen](https://github.com/tvdeyen))
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -1,13 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
|
-
branch = ENV.fetch('SOLIDUS_BRANCH', '
|
4
|
-
gem
|
5
|
+
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
6
|
+
gem 'solidus', git: 'https://github.com/solidusio/solidus.git', branch: branch
|
7
|
+
|
8
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
9
|
+
# otherwise it takes forever to resolve them
|
10
|
+
if branch == 'master' || Gem::Version.new(branch[1..-1]) >= Gem::Version.new('2.10.0')
|
11
|
+
gem 'rails', '~> 6.0'
|
12
|
+
else
|
13
|
+
gem 'rails', '~> 5.2'
|
14
|
+
end
|
5
15
|
|
6
16
|
case ENV['DB']
|
7
|
-
when 'mysql'
|
8
|
-
gem 'mysql2'
|
9
17
|
when 'postgresql'
|
10
18
|
gem 'pg'
|
19
|
+
when 'mysql'
|
20
|
+
gem 'mysql2'
|
21
|
+
else
|
22
|
+
gem 'sqlite3'
|
11
23
|
end
|
12
24
|
|
25
|
+
gem 'solidus_extension_dev_tools', github: 'solidusio-contrib/solidus_extension_dev_tools'
|
26
|
+
|
13
27
|
gemspec
|
data/Guardfile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
guard 'rspec', cmd: 'bundle exec rspec' do
|
2
4
|
watch('spec/spec_helper.rb') { 'spec' }
|
3
5
|
watch('config/routes.rb') { 'spec/controllers' }
|
4
6
|
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
|
5
|
-
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
|
7
|
+
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
6
8
|
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
9
|
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
|
8
10
|
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
|
data/README.md
CHANGED
@@ -1,24 +1,33 @@
|
|
1
1
|
# Volume Pricing
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_volume_pricing.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_volume_pricing)
|
4
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
5
|
|
6
|
-
Volume Pricing is an extension to Solidus that uses predefined ranges of quantities to determine the
|
6
|
+
Volume Pricing is an extension to Solidus that uses predefined ranges of quantities to determine the
|
7
|
+
price for a particular product variant.
|
8
|
+
|
9
|
+
For instance, this allows you to set a price for quantities between 1-10, another price for
|
10
|
+
quantities between (10-100) and another for quantities of 100 or more. If no volume price is defined
|
11
|
+
for a variant, then the standard price is used.
|
7
12
|
|
8
13
|
Each VolumePrice contains the following values:
|
9
14
|
|
10
|
-
1. **Variant:** Each VolumePrice is associated with a _Variant_, which is used to link products to
|
11
|
-
|
12
|
-
1. **
|
13
|
-
1. **
|
15
|
+
1. **Variant:** Each VolumePrice is associated with a _Variant_, which is used to link products to
|
16
|
+
particular prices.
|
17
|
+
1. **Name:** The human readable representation of the quantity range (Ex. 10-100). (Optional)
|
18
|
+
1. **Discount Type** The type of discount to apply. **Price:** sets price to the amount specified.
|
19
|
+
* **Dollar:** subtracts specified amount from the Variant price.
|
20
|
+
* **Percent:** subtracts the specified amounts percentage from the Variant price.
|
21
|
+
1. **Range:** The quantity range for which the price is valid (See Below for Examples of Valid
|
22
|
+
Ranges.)
|
14
23
|
1. **Amount:** The price of the product if the line item quantity falls within the specified range.
|
15
24
|
1. **Position:** Integer value for `acts_as_list` (Helps keep the volume prices in a defined order.)
|
16
25
|
|
17
|
-
---
|
18
|
-
|
19
26
|
## Install
|
20
27
|
|
21
|
-
The extension contains a rails generator that will add the necessary migrations and give you the
|
28
|
+
The extension contains a rails generator that will add the necessary migrations and give you the
|
29
|
+
option to run the migrations, or run them later, perhaps after installing other extensions. Once you
|
30
|
+
have bundled the extension, run the install generator and its ready to use.
|
22
31
|
|
23
32
|
rails generate solidus_volume_pricing:install
|
24
33
|
|
@@ -26,85 +35,81 @@ Easily add volume pricing display to your product page:
|
|
26
35
|
|
27
36
|
<%= render partial: 'spree/products/volume_pricing', locals: { product: @product } %>
|
28
37
|
|
29
|
-
---
|
30
|
-
|
31
38
|
## Ranges
|
32
39
|
|
33
|
-
Ranges are expressed as Strings and are similar to the format of a Range object in Ruby.
|
40
|
+
Ranges are expressed as Strings and are similar to the format of a Range object in Ruby. The lower
|
41
|
+
number of the range is always inclusive. If the range is defined with '..' then it also includes
|
42
|
+
the upper end of the range. If the range is defined with '...' then the upper end of the range is
|
43
|
+
not inclusive.
|
34
44
|
|
35
|
-
Ranges can also be defined as "open ended." Open ended ranges are defined with an integer followed
|
45
|
+
Ranges can also be defined as "open ended." Open ended ranges are defined with an integer followed
|
46
|
+
by a '+' character. These ranges are inclusive of the integer and any value higher then the
|
47
|
+
integer.
|
36
48
|
|
37
|
-
All ranges need to be expressed as Strings and can include or exclude parentheses. "(1..10)" and
|
38
|
-
|
39
|
-
---
|
49
|
+
All ranges need to be expressed as Strings and can include or exclude parentheses. "(1..10)" and
|
50
|
+
"1..10" are considered to be a valid range.
|
40
51
|
|
41
52
|
## Examples
|
42
53
|
|
43
54
|
Consider the following examples of volume prices:
|
44
55
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
56
|
+
| Variant | Name | Range | Amount | Position |
|
57
|
+
| ------- | ---- | ----- | ------ | -------- |
|
58
|
+
| Rails T-Shirt | 1-5 | (1..5) | 19.99 | 1 |
|
59
|
+
| Rails T-Shirt | 6-9 | (6...10) | 18.99 | 2 |
|
60
|
+
| Rails T-Shirt | 10 or more | (10+) | 17.99 | 3 |
|
50
61
|
|
51
62
|
### Example 1
|
52
63
|
|
53
64
|
Cart Contents:
|
54
65
|
|
55
|
-
|
56
|
-
|
57
|
-
|
66
|
+
| Product | Quantity | Price | Total |
|
67
|
+
| ------- | -------- | ----- | ----- |
|
68
|
+
| Rails T-Shirt | 1 | 19.99 | 19.99 |
|
58
69
|
|
59
70
|
### Example 2
|
60
71
|
|
61
72
|
Cart Contents:
|
62
73
|
|
63
|
-
|
64
|
-
|
65
|
-
|
74
|
+
| Product | Quantity | Price | Total |
|
75
|
+
| ------- | -------- | ----- | ----- |
|
76
|
+
| Rails T-Shirt | 5 | 19.99 | 99.95 |
|
66
77
|
|
67
78
|
### Example 3
|
68
79
|
|
69
80
|
Cart Contents:
|
70
81
|
|
71
|
-
|
72
|
-
|
73
|
-
|
82
|
+
| Product | Quantity | Price | Total |
|
83
|
+
| ------- | -------- | ----- | ----- |
|
84
|
+
| Rails T-Shirt | 6 | 18.99 | 113.94 |
|
74
85
|
|
75
86
|
### Example 4
|
76
87
|
|
77
88
|
Cart Contents:
|
78
89
|
|
79
|
-
|
80
|
-
|
81
|
-
|
90
|
+
| Product | Quantity | Price | Total |
|
91
|
+
| ------- | -------- | ----- | ----- |
|
92
|
+
| Rails T-Shirt | 10 | 17.99 | 179.90 |
|
82
93
|
|
83
94
|
### Example 5
|
84
95
|
|
85
96
|
Cart Contents:
|
86
97
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
---
|
98
|
+
| Product | Quantity | Price | Total |
|
99
|
+
| ------- | -------- | ----- | ----- |
|
100
|
+
| Rails T-Shirt | 20 | 17.99 | 359.80 |
|
92
101
|
|
93
102
|
## Additional Notes
|
94
103
|
|
95
|
-
* The volume price is applied based on the total quantity ordered for a particular variant.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
## Contributing
|
100
|
-
|
101
|
-
See corresponding [contributing guidelines][1].
|
102
|
-
|
103
|
-
---
|
104
|
+
* The volume price is applied based on the total quantity ordered for a particular variant. It does
|
105
|
+
not apply different prices for the portion of the quantity that falls within a particular range.
|
106
|
+
Only the one price is used (although this would be an interesting configurable option if someone
|
107
|
+
wanted to write a patch.)
|
104
108
|
|
105
109
|
## License
|
106
110
|
|
107
|
-
Copyright (c) 2009-2015 [Spree Commerce][2] and [contributors][3], released under the
|
111
|
+
Copyright (c) 2009-2015 [Spree Commerce][2] and [contributors][3], released under the
|
112
|
+
[New BSD License][4].
|
108
113
|
|
109
114
|
[1]: https://github.com/solidusio-contrib/solidus_volume_pricing/blob/master/CONTRIBUTING.md
|
110
115
|
[2]: https://github.com/spree
|