Code Monkey home page Code Monkey logo

spree_volume_pricing's Introduction

Volume Pricing

Build Status Code Climate

Volume Pricing is an extension to Spree (a complete open source commerce solution for Ruby on Rails) 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.

Each VolumePrice contains the following values:

  1. Variant: Each VolumePrice is associated with a Variant, which is used to link products to particular prices.
  2. Name: The human readable representation of the quantity range (Ex. 10-100). (Optional)
  3. 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.
  4. Range: The quantity range for which the price is valid (See Below for Examples of Valid Ranges.)
  5. Amount: The price of the product if the line item quantity falls within the specified range.
  6. Position: Integer value for acts_as_list (Helps keep the volume prices in a defined order.)

Install

Add in your Gemfile:

gem 'spree_volume_pricing', github: 'spree-contrib/spree_volume_pricing'

(run bundle install)

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.

  rails generate spree_volume_pricing:install

Easily add volume pricing display to your product page:

  <%= render partial: 'spree/products/volume_pricing', locals: { product: @product } %>

Ranges

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.

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.

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.


Examples

Consider the following examples of volume prices:

   Variant                Name               Range        Amount         Position
   -------------------------------------------------------------------------------
   Rails T-Shirt          1-5                (1..5)       19.99          1
   Rails T-Shirt          6-9                (6...10)     18.99          2
   Rails T-Shirt          10 or more         (10+)        17.99          3

Example 1

Cart Contents:

   Product                Quantity       Price       Total
   ----------------------------------------------------------------
   Rails T-Shirt          1              19.99       19.99

Example 2

Cart Contents:

   Product                Quantity       Price       Total
   ----------------------------------------------------------------
   Rails T-Shirt          5              19.99       99.95

Example 3

Cart Contents:

  Product                Quantity       Price       Total
  ----------------------------------------------------------------
  Rails T-Shirt          6              18.99       113.94

Example 4

Cart Contents:

  Product                Quantity       Price       Total
  ----------------------------------------------------------------
  Rails T-Shirt          10             17.99       179.90

Example 5

Cart Contents:

  Product                Quantity       Price       Total
  ----------------------------------------------------------------
  Rails T-Shirt          20             17.99       359.80

Additional Notes

  • 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.)

Contributing

See corresponding contributing guidelines.


License

Copyright (c) 2009-2021 Spree Commerce and contributors, released under the New BSD License

spree_volume_pricing's People

Contributors

aplegatt avatar bbonislawski avatar bdq avatar cluster444 avatar damianlegawiec avatar drefined avatar futhr avatar iloveitaly avatar jdutil avatar jeffschuil avatar jspizziri avatar jsqu99 avatar lani13 avatar matthewkennedy avatar mattmcginnis avatar paulsponagl avatar pszyszkaspark avatar quintinadam avatar radar avatar redglory avatar romul avatar schof avatar scudco avatar sevenseacat avatar shaggyone avatar szymoniwacz avatar timothyjoh avatar vygovskysergey avatar webster322 avatar witekl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spree_volume_pricing's Issues

db migrate failure: 20121115043422 AddDiscountTypeColumn

== 20121115043422 AddDiscountTypeColumn: migrating ============================
-- add_column(:spree_volume_prices, :discount_type, :string)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: duplicate column name: discount_type: ALTER TABLE "spree_ volume_prices" ADD "discount_type" varchar
/usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in initialize' /usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in new'
/usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in prepare' /usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:137:i n execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:232:in block in execute' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:589:in block in log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/notif ications/instrumenter.rb:21:in instrument' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:583:in log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:232:in execute' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/schema_statements.rb:542:in add_column'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:373:in add_column' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:846:in block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:815:in block in say_with_time' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:815:in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:835:in method_missing' /var/opt/gitlab/git-data/repositories/ypil-shahzeb/db/migrate/20121115043422_add _discount_type_column.rb:3:in change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:789:in exec_migration' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:773:in block (2 levels) in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:772:in block in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/connection_pool.rb:398:in with_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:771:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on/compatibility.rb:121:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:951:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1212:in block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1280:in block in ddl_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/database_statements.rb:232:in block in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/transaction.rb:189:in within_new_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/database_statements.rb:232:in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/transac tions.rb:211:in transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1280:in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1211:in execute_migration_in_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1184:in block in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1183:in each' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1183:in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1134:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1006:in up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:984:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/tasks/d atabase_tasks.rb:161:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/railtie s/databases.rake:58:in block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/rake_proxy .rb:14:in block in run_rake_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/rake_proxy .rb:11:in run_rake_task' /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_t asks.rb:51:in run_command!'
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in <top (required)>' bin/rails:4:inrequire'
bin/rails:4:in <main>' ActiveRecord::StatementInvalid: SQLite3::SQLException: duplicate column name: di scount_type: ALTER TABLE "spree_volume_prices" ADD "discount_type" varchar /usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in initialize'
/usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in new' /usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in prepare'
/usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:137:i n execute' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:232:in block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:589:in block in log' /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/notif ications/instrumenter.rb:21:in instrument'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:583:in log' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:232:in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/schema_statements.rb:542:in add_column' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:373:in add_column'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:846:in block in method_missing' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:815:in block in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:815:in say_with_time' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:835:in method_missing'
/var/opt/gitlab/git-data/repositories/ypil-shahzeb/db/migrate/20121115043422_add _discount_type_column.rb:3:in change' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:789:in exec_migration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:773:in block (2 levels) in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:772:in block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/connection_pool.rb:398:in with_connection' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:771:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on/compatibility.rb:121:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:951:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1212:in block in execute_migration_in_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1280:in block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/database_statements.rb:232:in block in transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/transaction.rb:189:in within_new_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/database_statements.rb:232:in transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/transac tions.rb:211:in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1280:in ddl_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1211:in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1184:in block in migrate_without_lock' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1183:in each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1183:in migrate_without_lock' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1134:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1006:in up' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:984:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/tasks/d atabase_tasks.rb:161:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/railtie s/databases.rake:58:in block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/rake_proxy .rb:14:in block in run_rake_task' /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/rake_proxy .rb:11:in run_rake_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_t asks.rb:51:in run_command!' /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in <top (required)>'
bin/rails:4:in require' bin/rails:4:in

'
SQLite3::SQLException: duplicate column name: discount_type
/usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in initialize' /usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in new'
/usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in prepare' /usr/local/rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:137:i n execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:232:in block in execute' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:589:in block in log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/notif ications/instrumenter.rb:21:in instrument' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:583:in log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:232:in execute' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/schema_statements.rb:542:in add_column'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/sqlite3_adapter.rb:373:in add_column' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:846:in block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:815:in block in say_with_time' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:815:in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:835:in method_missing' /var/opt/gitlab/git-data/repositories/ypil-shahzeb/db/migrate/20121115043422_add _discount_type_column.rb:3:in change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:789:in exec_migration' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:773:in block (2 levels) in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:772:in block in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/connection_pool.rb:398:in with_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:771:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on/compatibility.rb:121:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:951:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1212:in block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1280:in block in ddl_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/database_statements.rb:232:in block in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/transaction.rb:189:in within_new_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connect ion_adapters/abstract/database_statements.rb:232:in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/transac tions.rb:211:in transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1280:in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1211:in execute_migration_in_transaction' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1184:in block in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1183:in each' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1183:in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1134:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:1006:in up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/migrati on.rb:984:in migrate' /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/tasks/d atabase_tasks.rb:161:in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/railtie s/databases.rake:58:in block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/rake_proxy .rb:14:in block in run_rake_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/rake_proxy .rb:11:in run_rake_task' /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_t asks.rb:51:in run_command!'
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in <top (required)>' bin/rails:4:inrequire'
bin/rails:4:in `'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Can't Add Quantity Discounts Pricing

In volume_prices.html.erb you can't add the first volume discount price. By changing line 23 to <%= link_to_add_fields t(:add_volume_price), "tbody#volume_prices" %> I was able to get the page to load but there were no fields available to create a volume discount.

If I manually added a quantity discount price for that item into the database then the values from the database would show up on the product volume pricing page and clicking the add volume pricing link would insert new fields into the page that could be filled in and updated properly.

Partial only ever displays master variant pricing

Steps to repeat:

  • Install spree 2.1

  • load spree sample data

  • Install this gem (2.1)

  • Create examples in the admin interface (these examples from the README.md)

    Variant                Name               Range        Amount         Position
     -------------------------------------------------------------------------------
    Rails T-Shirt          1-5                (1..5)       19.99          1
    Rails T-Shirt          6-9                (6...10)     18.99          2
    Rails T-Shirt          10 or more         (10+)        17.99          3
    
  • Create your own product page (copy it from the spree gem): app/views/spree/products/show.html.erb

  • add the partial to you overridden product page

    <%= render :partial => 'spree/products/volume_pricing', :locals => { :product => @product } %>
    
  • start your webserver

  • Navigate to the product page

The problem:
Strictly a display issue only: clicking the different images of the product changes the product image, but the partial only ever displays the pricing from the master.

As far as I can tell the correct price is used when you click the variant and add to your cart, but it'd be confusing for a user if you had different volume prices per variant but they are only displayed the master one.

Gemfile

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]


# spree stuff
gem 'spree', git: 'https://github.com/spree/spree.git', :branch => '2-1-stable'
gem 'spree_paypal_express', :git => 'https://github.com/radar/better_spree_paypal_express.git', :branch => '2-1-stable'
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => '2-1-stable'
gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', :branch => '2-1-stable'
gem 'spree_volume_pricing', :git => 'https://github.com/spree/spree_volume_pricing.git', :branch => '2-1-stable'

Broken developer setup with Spree 0.70 out of the box

The gemspec's spree_core dependency is listed as >= 0.70.0, which means that it installs Spree 1.0.3 as of 2 April 2012 when running bundle install. The Rakefile also does not use Bundler to setup the load paths.

api v2 support

Documentation is missing what needs to be passed to api2 to be included in the product response. Maybe, there is no api v2 support. In general I did not see if this is already compatible with spree 4.x (although it could be included w/o errors into my project).

So my questions / recommendations / issues:

  • How to use with apiv2?
  • What spree Versions are supported?

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler found conflicting requirements for the Ruby version:
  In Gemfile:
    Ruby (~> 2.2.10.0)

    spree_dev_tools was resolved to 0.1.8, which depends on
      Ruby (>= 2.3.0)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Cart prices are not showing properly

I created a variant volume price and added the 2x products of that variant to the cart. The price is not affected at all, until I change the item amount to 3x, update the cart and then change it back to 2x.

The price volume has a range of 2..2. I want to make a discount when you just get two items instead of one.

Any clues?

undefined method `money' for #<#<Class:0x007fce981445d8>:0x007fce98580cf0>

I've got a pretty vanilla spree 2.1 app and I'm getting this error. Tried overriding with deface and with a view override, same error. Overriding 'spree/products/show'

Full trace here:
Showing /Users/kevin/.rvm/gems/ruby-2.0.0-p247@lp/bundler/gems/spree_volume_pricing-db5936ae86b6/app/views/spree/products/_volume_pricing.html.erb where line #9 raised:

undefined method `money' for #<#Class:0x007fce981445d8:0x007fce98580cf0>
Extracted source (around line #9):

<% product.master.volume_prices.each do |v| %>
<%= content_tag(:tr) do %>
<%= content_tag :td, (v.open_ended? ? v.range : "#{v.range.to_range.begin}โ€“#{v.range.to_range.end}") %>
<%= content_tag :td, money(v.amount)%>
<%= content_tag(:td, "%i%" % ((1.0 - v.amount / product.master.price) * 100.0).round) if display_percent %>
<% end %>
<% end %>   

Trace of template inclusion: app/views/spree/products/show.html.erb

Rails.root: /Users/kevin/rails/lp

Application Trace | Framework Trace | Full Trace
spree_core (2.1.3) app/helpers/spree/base_helper.rb:149:in method_missing' /Users/kevin/.rvm/gems/ruby-2.0.0-p247@lp/bundler/gems/spree_volume_pricing-db5936ae86b6/app/views/spree/products/_volume_pricing.html.erb:9:inblock (2 levels) in _74b2cf15754a818a3cae3ffddcaed579'
actionpack (4.0.1) lib/action_view/helpers/capture_helper.rb:38:in block in capture' actionpack (4.0.1) lib/action_view/helpers/capture_helper.rb:200:inwith_output_buffer'
actionpack (4.0.1) lib/action_view/helpers/capture_helper.rb:38:in capture' actionpack (4.0.1) lib/action_view/helpers/tag_helper.rb:94:incontent_tag'
/Users/kevin/.rvm/gems/ruby-2.0.0-p247@lp/bundler/gems/spree_volume_pricing-db5936ae86b6/app/views/spree/products/_volume_pricing.html.erb:7:in block in _74b2cf15754a818a3cae3ffddcaed579' activerecord (4.0.1) lib/active_record/relation/delegation.rb:13:ineach'
activerecord (4.0.1) lib/active_record/relation/delegation.rb:13:in each' /Users/kevin/.rvm/gems/ruby-2.0.0-p247@lp/bundler/gems/spree_volume_pricing-db5936ae86b6/app/views/spree/products/_volume_pricing.html.erb:6:in_74b2cf15754a818a3cae3ffddcaed579'
actionpack (4.0.1) lib/action_view/template.rb:143:in block in render' activesupport (4.0.1) lib/active_support/notifications.rb:161:ininstrument'
actionpack (4.0.1) lib/action_view/template.rb:141:in render' deface (1.0.0) lib/deface/action_view_extensions.rb:41:inrender'
actionpack (4.0.1) lib/action_view/renderer/partial_renderer.rb:306:in render_partial' actionpack (4.0.1) lib/action_view/renderer/partial_renderer.rb:279:inblock in render'
actionpack (4.0.1) lib/action_view/renderer/abstract_renderer.rb:38:in block in instrument' activesupport (4.0.1) lib/active_support/notifications.rb:159:inblock in instrument'
activesupport (4.0.1) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.0.1) lib/active_support/notifications.rb:159:ininstrument'
actionpack (4.0.1) lib/action_view/renderer/abstract_renderer.rb:38:in instrument' actionpack (4.0.1) lib/action_view/renderer/partial_renderer.rb:278:inrender'
actionpack (4.0.1) lib/action_view/renderer/renderer.rb:47:in render_partial' actionpack (4.0.1) lib/action_view/renderer/renderer.rb:21:inrender'
actionpack (4.0.1) lib/action_view/helpers/rendering_helper.rb:24:in render' app/views/spree/products/show.html.erb:59:in_1ab74437d3c96891a1e4979c24536b47'
actionpack (4.0.1) lib/action_view/template.rb:143:in block in render' activesupport (4.0.1) lib/active_support/notifications.rb:161:ininstrument'
actionpack (4.0.1) lib/action_view/template.rb:141:in render' deface (1.0.0) lib/deface/action_view_extensions.rb:41:inrender'
actionpack (4.0.1) lib/action_view/renderer/template_renderer.rb:49:in block (2 levels) in render_template' actionpack (4.0.1) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument'
activesupport (4.0.1) lib/active_support/notifications.rb:159:in block in instrument' activesupport (4.0.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.0.1) lib/active_support/notifications.rb:159:in instrument' actionpack (4.0.1) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument'
actionpack (4.0.1) lib/action_view/renderer/template_renderer.rb:48:in block in render_template' actionpack (4.0.1) lib/action_view/renderer/template_renderer.rb:56:inrender_with_layout'
actionpack (4.0.1) lib/action_view/renderer/template_renderer.rb:47:in render_template' actionpack (4.0.1) lib/action_view/renderer/template_renderer.rb:17:inrender'
actionpack (4.0.1) lib/action_view/renderer/renderer.rb:42:in render_template' actionpack (4.0.1) lib/action_view/renderer/renderer.rb:23:inrender'
actionpack (4.0.1) lib/abstract_controller/rendering.rb:127:in _render_template' actionpack (4.0.1) lib/action_controller/metal/streaming.rb:219:in_render_template'
actionpack (4.0.1) lib/abstract_controller/rendering.rb:120:in render_to_body' actionpack (4.0.1) lib/action_controller/metal/rendering.rb:33:inrender_to_body'
actionpack (4.0.1) lib/action_controller/metal/renderers.rb:26:in render_to_body' actionpack (4.0.1) lib/abstract_controller/rendering.rb:97:inrender'
actionpack (4.0.1) lib/action_controller/metal/rendering.rb:16:in render' actionpack (4.0.1) lib/action_controller/metal/instrumentation.rb:41:inblock (2 levels) in render'
activesupport (4.0.1) lib/active_support/core_ext/benchmark.rb:12:in block in ms' /Users/kevin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/benchmark.rb:296:inrealtime'
activesupport (4.0.1) lib/active_support/core_ext/benchmark.rb:12:in ms' actionpack (4.0.1) lib/action_controller/metal/instrumentation.rb:41:inblock in render'
actionpack (4.0.1) lib/action_controller/metal/instrumentation.rb:84:in cleanup_view_runtime' activerecord (4.0.1) lib/active_record/railties/controller_runtime.rb:25:incleanup_view_runtime'
actionpack (4.0.1) lib/action_controller/metal/instrumentation.rb:40:in render' actionpack (4.0.1) lib/action_controller/metal/implicit_render.rb:10:indefault_render'
actionpack (4.0.1) lib/action_controller/metal/implicit_render.rb:5:in send_action' actionpack (4.0.1) lib/abstract_controller/base.rb:189:inprocess_action'
actionpack (4.0.1) lib/action_controller/metal/rendering.rb:10:in process_action' actionpack (4.0.1) lib/abstract_controller/callbacks.rb:18:inblock in process_action'
activesupport (4.0.1) lib/active_support/callbacks.rb:463:in _run__2610627698034856779__process_action__callbacks' activesupport (4.0.1) lib/active_support/callbacks.rb:80:inrun_callbacks'
actionpack (4.0.1) lib/abstract_controller/callbacks.rb:17:in process_action' actionpack (4.0.1) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.0.1) lib/action_controller/metal/instrumentation.rb:31:in block in process_action' activesupport (4.0.1) lib/active_support/notifications.rb:159:inblock in instrument'
activesupport (4.0.1) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.0.1) lib/active_support/notifications.rb:159:ininstrument'
actionpack (4.0.1) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.0.1) lib/action_controller/metal/params_wrapper.rb:245:inprocess_action'
activerecord (4.0.1) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.0.1) lib/abstract_controller/base.rb:136:inprocess'
actionpack (4.0.1) lib/abstract_controller/rendering.rb:44:in process' actionpack (4.0.1) lib/action_controller/metal.rb:195:indispatch'
actionpack (4.0.1) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.0.1) lib/action_controller/metal.rb:231:inblock in action'
actionpack (4.0.1) lib/action_dispatch/routing/route_set.rb:80:in call' actionpack (4.0.1) lib/action_dispatch/routing/route_set.rb:80:indispatch'
actionpack (4.0.1) lib/action_dispatch/routing/route_set.rb:48:in call' actionpack (4.0.1) lib/action_dispatch/journey/router.rb:71:inblock in call'
actionpack (4.0.1) lib/action_dispatch/journey/router.rb:59:in each' actionpack (4.0.1) lib/action_dispatch/journey/router.rb:59:incall'
actionpack (4.0.1) lib/action_dispatch/routing/route_set.rb:680:in call' railties (4.0.1) lib/rails/engine.rb:511:incall'
railties (4.0.1) lib/rails/railtie/configurable.rb:30:in method_missing' actionpack (4.0.1) lib/action_dispatch/journey/router.rb:71:inblock in call'
actionpack (4.0.1) lib/action_dispatch/journey/router.rb:59:in each' actionpack (4.0.1) lib/action_dispatch/journey/router.rb:59:incall'
actionpack (4.0.1) lib/action_dispatch/routing/route_set.rb:680:in call' warden (1.2.3) lib/warden/manager.rb:35:inblock in call'
warden (1.2.3) lib/warden/manager.rb:34:in catch' warden (1.2.3) lib/warden/manager.rb:34:incall'
rack (1.5.2) lib/rack/etag.rb:23:in call' rack (1.5.2) lib/rack/conditionalget.rb:25:incall'
rack (1.5.2) lib/rack/head.rb:11:in call' actionpack (4.0.1) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.0.1) lib/action_dispatch/middleware/flash.rb:241:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.0.1) lib/action_dispatch/middleware/cookies.rb:486:incall'
activerecord (4.0.1) lib/active_record/query_cache.rb:36:in call' activerecord (4.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:incall'
activerecord (4.0.1) lib/active_record/migration.rb:369:in call' actionpack (4.0.1) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.0.1) lib/active_support/callbacks.rb:373:in _run__1404216191509272203__call__callbacks' activesupport (4.0.1) lib/active_support/callbacks.rb:80:inrun_callbacks'
actionpack (4.0.1) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.0.1) lib/action_dispatch/middleware/reloader.rb:64:incall'
actionpack (4.0.1) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.0.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.1) lib/rails/rack/logger.rb:38:incall_app'
railties (4.0.1) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.0.1) lib/active_support/tagged_logging.rb:67:inblock in tagged'
activesupport (4.0.1) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.1) lib/active_support/tagged_logging.rb:67:intagged'
railties (4.0.1) lib/rails/rack/logger.rb:20:in call' actionpack (4.0.1) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall'
activesupport (4.0.1) lib/active_support/cache/strategy/local_cache.rb:83:in call' rack (1.5.2) lib/rack/lock.rb:17:incall'
actionpack (4.0.1) lib/action_dispatch/middleware/static.rb:64:in call' rack (1.5.2) lib/rack/sendfile.rb:112:incall'
railties (4.0.1) lib/rails/engine.rb:511:in call' railties (4.0.1) lib/rails/application.rb:97:incall'
rack (1.5.2) lib/rack/lock.rb:17:in call' rack (1.5.2) lib/rack/content_length.rb:14:incall'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in service' /Users/kevin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:inservice'
/Users/kevin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in run' /Users/kevin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:inblock in start_thread'

Enable/disable volume pricing

Is there any ability right now (or is it in the road map) to allow an easy way to temporarily disable volume pricing (similar to available_on column for Products)? One solution that comes to mind is an "Enabled" checkbox in the volume pricing views and stored in the VP table.

Bug is not updating my cart correctly

If I change to a inferior range vprice, the quantity price is not applied correctly in the shopping cart.
affecting 1-3-stable and master, line_item_decorator.rb

if (!new_price.nil? and vprice <= new_price) or vprice <= self.price

The following code is missing in the conditional...
or vprice >= self.price

update assets paths for 2-2-stable

I'm getting the following error while trying to install this gem.

gem 'spree_volume_pricing', github: 'spree/spree_volume_pricing', branch: '2-2-stable'
$ rails g spree_volume_pricing:install

[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
Instance method "open" is already defined in Object, use generic helper instead or set StateMachine::Machine.ignore_method_conflicts = true.
      append  app/assets/javascripts/admin/all.js
/var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `binread': No such file or directory - /media/data/Projects/Dromit/store/app/assets/javascripts/admin/all.js (Errno::ENOENT)
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `replace!'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:59:in `invoke!'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:30:in `insert_into_file'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:180:in `append_to_file'
    from /home/matias/.bundler/ruby/1.9.1/spree_volume_pricing-11cb113a1fb9/lib/generators/spree_volume_pricing/install_generator.rb:6:in `add_javascripts'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /var/lib/gems/1.9.1/gems/railties-4.0.4/lib/rails/generators.rb:156:in `invoke'
    from /var/lib/gems/1.9.1/gems/railties-4.0.4/lib/rails/commands/generate.rb:11:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
    from /var/lib/gems/1.9.1/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/1.9.1/gems/railties-4.0.4/lib/rails/commands.rb:48:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

No translation for discount type

Hi Guys,

I am translating the gem but I noticed that the dropdown list of discount type cannot be translated. Will try to submit a fix for this soon.

Issues with reload! after installing

I installed this gem following the instructions (2-1-stable). The gem seems to function, but now if I'm in a rails console and I type reload! I get an error about 'admin_volumn_price' being defined twice.

Steps to reproduce:

gem install rails -v 4.0.0
rails _4.0.0_ new my_store2

added the following to my Gemfile

gem 'spree', github: 'spree/spree', branch: '2-1-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-1-stable'
gem 'spree_volume_pricing', github: 'spree/spree_volume_pricing', branch: '2-1-stable'

run bundle install

run the installer

rails generate spree_volume_pricing:install

Fire up a rails console and type reload!

>rails c
Loading development environment (Rails 4.0.0)
2.0.0p247 :001 > reload!
Reloading...
ArgumentError: Invalid route name, already in use: 'admin_volume_price'
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
    from /Users/hirbourj/.rvm/gems/ruby-2.0.0-p247@spreestoretestvolumnpricing/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:409:in `add_route'

I checked and I only see "admin_volume_price" in rake routes 1 time.

My routes file:

MyStore2::Application.routes.draw do
  mount Spree::Core::Engine, :at => '/'
end

cart prices not effected

When I am set volume range and prices then we make a cart then the prices not changed according to range price

Can't install

After adding the gem to my gemfile if I run:

rails generate spree_volume_pricing:install

I get the error:

../.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- coffee_script (LoadError)

The required "coffee_script" is in /lib/spree_volume_pricing.rb
Gem coffee-rails has its reported status as failing (https://github.com/rails/coffee-rails)

You can remove this requirement because all the javascript files are written in jquery.

Proposed New Features - Pricing Models & Roles

First, great work guys, thank you for building this gem.

There are a few features that I would like to propose that be built (I'm not opposed to contributing).

  1. Abstract the volume prices a bit by providing attaching them to a Volume Pricing Model, attach the model to the variants rather than the volume prices themselves. This would allow the definition of a few abstract pricing models that could be applied to N products/variants. Updates on each pricing model would propagate to every item using that model.
  2. Add the ability to specify a role on volume prices/volume pricing models. This would allow different pricing models for different users, which is necessary in the case of wholesaling etc.
  3. I saw another issue #45, which discussed adding a volume pricing to the product which would be applied for every variant belonging to that product. I similarly think this would be a good idea, and perhaps a good build to roll it up into.

What say you?

Error when trying to install

I'm trying to run the install task in my able but I am getting this error

uninitialized constant SpreeVolumePricing::Engine::Variant (NameError)
Gemfile
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'unicorn'

gem 'spree', github: 'spree/spree', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'spree_volume_pricing'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

The volume pricing does not work on variants

Hi there,

I just made a product, and volume pricing works perfectly.

However, once i make two variants of the product, the volume pricing no longer applies when i place a product in my shopping cart.

Any ideas? Mayby i have to re-add the volume pricing after defining variants?

I'm using the "2-3-stable" branch.

Nice work on the gem btw:)

Paul

String#to_range not working properly

Hello everyone.

reproduce:
bundle exec rails console
"10..20".to_range # => 0..20 but should be 10..20

The first digit of the first number is ignored.

The error is in engine.rb the two from-calls in lines 17 and 20 should just not be there.

Volume pricing for product total

Something that has come up before with volume pricing is being able to have it applied to the whole product. An example should make this easier to understand.

You supply uniforms they are often purchased by groups when new recruits join, this can often happen in batches. The group maybe ordering 10 t-shirts but they would be in various sizes. 3 Small, 6 Medium and 1 Large for example. Your volume pricing starts at 10 items per variant but it is unlikely your customers would ever purchase so many of a single size but combining all the sizes in the basket would often qualify.

In the example above you may wish to apply the volume price for each variant based on the total number of products not just the quantity of the individual variant.

So perhaps in the product there is an option to indicate total product quantity volume pricing (total of all variants in cart) or keep the current per variant volume pricing (total per variant).

Hopefully that make sense! My initial thoughts are to use the line items to find the other variants of the same product, sum the line item quantities together and pass that through to the volume price finder for each line item.

Open to the floor for feedback in case this is all complete madness.

"update.before" wrong number of arguments - (0 for 1)

I've been struggling with this issue for 2 days now... I give up :). Is this a bug, or my environment?

I'm using pow in my dev environment, but also tested booting webrick to make sure. I have several other spree extensions that work, but spree_volume_pricing has given me nothing but grief:

ArgumentError: wrong number of arguments (0 for 1)
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/spree_core-0.60.1/lib/spree_core/action_callbacks.rb:13:in `before'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/bundler/gems/spree_volume_pricing-d7cd09f4ff7c/lib/spree_volume_pricing/engine.rb:82:in `block in activate'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/bundler/gems/spree_volume_pricing-d7cd09f4ff7c/lib/spree_volume_pricing/engine.rb:81:in `class_eval'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/bundler/gems/spree_volume_pricing-d7cd09f4ff7c/lib/spree_volume_pricing/engine.rb:81:in `activate'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:445:in `_run_prepare_callbacks'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/callbacks.rb:40:in `initialize'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:33:in `new'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:33:in `build'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `block in build'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `each'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `inject'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `build'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/application.rb:162:in `app'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/application/finisher.rb:35:in `block in <module:Finisher>'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
~/Developer/.rvm/gems/ruby-1.9.2-p180@spree_app/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
~/sites/spree_app/config/environment.rb:5:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
~/sites/spree_app/config.ru:3:in `block in <main>'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/sites/spree_app/config.ru:1:in `new'
~/sites/spree_app/config.ru:1:in `<main>'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/server.rb:50:in `eval'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/server.rb:50:in `load_config'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/server.rb:43:in `initialize'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/server.rb:13:in `new'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/server.rb:13:in `run'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/bin/nack_worker:4:in `<main>'

Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.0.9'
gem 'mysql2', '0.2.7'

# http://stackoverflow.com/questions/6085610/rails-rake-problems-uninitialized-constant-rakedsl
# http://twitter.com/#!/dhh/status/71966528744071169
gem "rake", "0.8.7"

gem 'formtastic' # spree_static_content is not including this for some reason...

gem 'haml-rails', '>= 0.3.4'
gem 'jquery-rails', '>= 0.2.6'
gem 'compass', '>= 0.10.6'
gem 'compass-960-plugin'

gem 'spree', '~> 0.60.0'
gem 'spree_enhanced_option_types',  :git => '[email protected]:joshuap/spree-enhanced-option-types.git'

gem 'spree_volume_pricing', :git => 'git://raw.github.com/spree/spree_volume_pricing.git', :ref => 'd7cd09f4ff7ce7f33857'

gem 'spree_advanced_cart',          :git => 'git://github.com/romul/spree_advanced_cart.git'
gem 'spree_static_content'
gem 'spree_editor',                 :git => 'git://github.com/romul/spree_editor.git'

gem 'fog'
gem 'whenever', :require => false
gem 'foreman'

# Use unicorn as the web server
gem 'unicorn'

group :development do
  gem 'hpricot'
  gem 'ruby_parser'
end

group :development, :test do
  #gem 'webrat'
  gem 'factory_girl_rails', '>= 1.0.1', :group => :test
  gem 'factory_girl_generator', '>= 0.0.1', :group => [:development, :test]
  gem 'rspec-rails', '>= 2.5.0', :group => [:development, :test]
  gem 'capistrano'
end

Any plans to support 1.3?

having this error in the admin backoffice after creating a volumen price.

Rendered /Users/hector/.rvm/gems/ruby-1.9.3-p125/bundler/gems/spree_volume_pricing-5b100077b370/app/views/spree/admin/variants/_volume_price_fields.html.erb (171.1ms)
Rendered /Users/hector/.rvm/gems/ruby-1.9.3-p125/bundler/gems/spree_volume_pricing-5b100077b370/app/views/spree/admin/variants/volume_prices.html.erb within spree/layouts/admin (237.3ms)
Completed 500 Internal Server Error in 305ms

ActionView::Template::Error (undefined method admin_volume_price_path' for #<#<Class:0x007fdc9a5bf328>:0x007fdc950f97f8>): 20: <%= f.text_field :position, :size => 3 %> 21: </td> 22: <td valign="actions"> 23: <%= link_to_remove_fields t("remove"), f %> 24: </td> 25: </tr> /Users/hector/.rvm/gems/ruby-1.9.3-p125/bundler/gems/spree-a896b4567d93/core/app/helpers/spree/base_helper.rb:162:inmethod_missing'

Install fails on sass dependency

With spree 3.7, rails 5.2
After installing the gem, when I run rails generate spree_volume_pricing:install
I get an error

gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- sass (LoadError)

Compatibility?

I am using Rails 3.0.2
and 'spree', '0.50.2'
ruby 1.8

bundle installs fine but i get this error on every generator

/usr/local/lib/ruby/gems/1.8/gems/spree_volume_pricing-3.0.2/lib/spree_volume_pricing/engine.rb:82:in activate': undefined local variable or methodparams' for Admin::VariantsController:Class (NameError)
from /usr/local/lib/ruby/gems/1.8/gems/spree_volume_pricing-3.0.2/lib/spree_volume_pricing/engine.rb:81:in class_eval' from /usr/local/lib/ruby/gems/1.8/gems/spree_volume_pricing-3.0.2/lib/spree_volume_pricing/engine.rb:81:inactivate'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in _callback_before_33' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:440:in_run_prepare_callbacks'
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/callbacks.rb:40:in initialize' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:33:innew'
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:33:in build' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:inbuild'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:209:in inject' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:ineach'
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in inject' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:inbuild'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:162:in build_middleware_stack' from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application/finisher.rb:35 from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:ininstance_exec'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in run' from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50:inrun_initializers'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in each' from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:inrun_initializers'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134:in initialize!' from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:insend'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in method_missing' from /Users/justinmcnally/Documents/Aptana Studio 3 Workspace/wdsstore/config/environment.rb:5 from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:inload_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:inload_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in require' from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:103:inrequire_environment!'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:16
from script/rails:6:in `require'
from script/rails:6

Percentage discount not behaving as expected

Using 2-1-stable '815c00317580'

The total price discount type works as expected, but percent discount with an amount of 10 (assuming this is 10% off), I instead get negative numbers when the qty is within my specified range...

Please advise.

Incompatible with spree_core 2.1.0.beta

Dependencies aren't compatible with latest spree_core revision

bundle install
  ...
  Bundler could not find compatible versions for gem "spree_core":
    In Gemfile:
      spree_volume_pricing (>= 0) ruby depends on
        spree_core (~> 2.0.0) ruby

      spree (>= 0) ruby depends on
        spree_core (2.1.0.beta)

Error when saving variant without volume pricing

I have some variants that don't require volume pricing and use the price built-in to Spree. When I try to update a particular variant, I get the following error message:

2 errors prohibited this record from being saved:
There were problems with the following fields:
Volume prices amount can't be blank
Volume prices range must be in one of the following formats: (a..b), (a...b), (a+)

Am I required to add a simple (1+) volume price for every variant, even if they don't have actual volume prices?

screenshot 2014-01-17 12 28 24

Volume prices only working when Item Total is less than 0

Volume prices only working when Item Total is less than 0.

In this example the item master price is $20.
screen shot 2017-12-07 at 1 25 12 pm
Here a discount of $2 should be applied to the order but it isn't.
screen shot 2017-12-07 at 1 26 58 pm
Now, when the discount is greater than the master price (item total is less than 0) everything works
screen shot 2017-12-07 at 1 33 16 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.