spree_recently_sold_products 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGQ0ZThmNzhlZDlkODFjNDRkYjM3MWVkNWJmYWUyNGIzMTQzYTRhNQ==
4
+ OGVhNDY3OTYwNjBiM2I5OTYwNWM3YWEyM2JiOWNlZmIxM2RmOGUwOA==
5
5
  data.tar.gz: !binary |-
6
- ODczMmU1MGE4M2ZmNTVjMGFlOTY1NzIyN2RkYTlmM2M3YmFiZDJmMQ==
6
+ ZjM1MThjYmRkMjRhYTM3OWE4Njg0ZjE5MTExOTE1Yzk1YzNhZWU2YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjNjYjA1YjVjYmVhOGEyNDYwOTRkOGM0OGQyZWFlOGM0ZjUzZWU2MTY1YTA3
10
- ODA3MzY4NWM1N2M4YTI1NzY5MWJhNThmNzg4NGUxMWZlODQ4MjIyOWVmY2Q5
11
- OTE1NWJkOGUwOTI2YmNhZmUyMDg2NzZmNmQwNzg3NTU0ZDVjZjc=
9
+ ZjZhOTFjMTgwMGIzZTc4OGE5YmQ4MjA5NTM1ZTA3ZjBjMjVlYWRlMTYzNjc5
10
+ YWMxMTUwNzRiNDA3Mzc0Nzc5YmIwNzU0ODEzOTBhOGJiYWEzMGE5YTU3ZGM2
11
+ NmI1YWQyZDQ2ODY5NmJlNTMzOTg5MjFhOTBkNWY5ODYxYjZlZTk=
12
12
  data.tar.gz: !binary |-
13
- ZWE4YzlhMjVhNzBmZjY2YmQ0ODA4OTVlNDcxY2NlZTczMGRmNzA1MjI0Njhi
14
- ZTRkYTAxYjFlZjgxOWQ0YWM3NjczOThjNWQ4MmQ5ZWY0YmJlY2E0ZGJmYjc2
15
- MmZjZjAxZTY2OWU1NDgyZTJjOWVjOGIzYzEwZDE2NjdjMTkyNGU=
13
+ YjFiM2FhMjU1ZTAyM2EwNGQ4NzQ0ZjRiZTdhMjZlNjQ4NWE3YThmMTc3NWQ4
14
+ ZGU4MWNkYTM4YjY3ZGYyYzgxM2U4Y2VhMjM4OGNkYjRjODVjODZkM2E4NmJm
15
+ YzI0ZjM1N2ZmN2NhMjc0ODY4ZDE0NjhmYzdmYzkwNGFlYTRiZDI=
data/README.md CHANGED
@@ -27,9 +27,34 @@ Customization
27
27
  -------------
28
28
  By default the recently sold products are displayed at the bottom. You
29
29
  can change this by overriding the view in `app/overrides/spree/add_recently_sold_product.rb`
30
+ ```ruby
31
+ Deface::Override.new(:virtual_path => 'spree/home/index',
32
+ :insert_bottom => "[data-hook='homepage_products']",
33
+ :partial => "/spree/home/recently_sold_products",
34
+ :disabled => false,
35
+ :name => 'add_recently_sold_product')
36
+ ```
37
+
38
+ Configuration
39
+ -------------
40
+
41
+ By default the 10 recently sold products are displyed here.
42
+
43
+ To change this, use `:recently_sold_product_limit` preference.
44
+
45
+ One possible solution is like:
46
+ ```ruby
47
+ # app/models/product_decorator.rb
48
+
49
+ Spree::Product.class_eval do
50
+ Spree::Config[:recently_sold_product_limit] = 5
51
+ end
52
+
53
+ ```
54
+
55
+ Note:
56
+ Once a preference is set, you will need to either set it back yourself to the default, if you want to use default preference value.
30
57
 
31
- To Do
32
- -------
33
- 1. Configuration for number of products to display.
58
+ NOTE: No migrations are required for this extension
34
59
 
35
- Copyright (c) 2014 [http://www.cuberoot.in](Cuberoot Software), released under the New BSD License
60
+ Copyright (c) 2014 [Cuberoot Software](http://www.cuberoot.in), released under the New BSD License
@@ -0,0 +1,4 @@
1
+ Spree::AppConfiguration.class_eval do
2
+ # preference for setting recently sold products limit
3
+ preference :recently_sold_product_limit, :integer, default: 10
4
+ end
@@ -1,10 +1,11 @@
1
1
  Spree::Product.class_eval do
2
2
  def self.recently_sold
3
3
  @sold_products = []
4
- @orders = Spree::Order.where("state = ?", "complete").order("created_at DESC").limit(10)
4
+ @orders =
5
+ Spree::Order.where('state = ?', 'complete').order('created_at DESC')
5
6
  @orders.each do |order|
6
7
  order.products.each do |product|
7
- if @sold_products.count <= 10
8
+ if @sold_products.count < Spree::Config[:recently_sold_product_limit]
8
9
  @sold_products << product
9
10
  @sold_products.uniq!
10
11
  else
@@ -12,6 +13,6 @@ Spree::Product.class_eval do
12
13
  end
13
14
  end
14
15
  end
15
- return @sold_products
16
+ @sold_products
16
17
  end
17
18
  end
@@ -2,9 +2,10 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_recently_sold_products'
5
- s.version = '0.2'
6
- s.summary = 'Add gem summary here'
7
- s.description = 'Add gem description here'
5
+ s.version = '0.3'
6
+ s.summary = 'Spree extension to display recently sold products.'
7
+ s.description = 'This extension displays a list of recently sold products on the home
8
+ page.'
8
9
  s.required_ruby_version = '>= 1.9.3'
9
10
 
10
11
  s.authors = ["deepalic"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_recently_sold_products
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - deepalic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -164,7 +164,8 @@ dependencies:
164
164
  - - ! '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
- description: Add gem description here
167
+ description: ! "This extension displays a list of recently sold products on the home\n
168
+ \ page."
168
169
  email:
169
170
  - deepalic@cuberoot.in
170
171
  executables: []
@@ -183,6 +184,7 @@ files:
183
184
  - app/assets/stylesheets/admin/spree_recently_sold_products.css
184
185
  - app/assets/stylesheets/store/spree_recently_sold_products.css
185
186
  - app/helpers/spree/base_helper_decorator.rb
187
+ - app/models/spree/app_configuration_decorator.rb
186
188
  - app/models/spree/product_decorator.rb
187
189
  - app/overrides/spree/add_recently_sold_product.rb
188
190
  - app/views/spree/home/_recently_sold_products.html.erb
@@ -218,6 +220,6 @@ rubyforge_project:
218
220
  rubygems_version: 2.1.11
219
221
  signing_key:
220
222
  specification_version: 4
221
- summary: Add gem summary here
223
+ summary: Spree extension to display recently sold products.
222
224
  test_files:
223
225
  - spec/spec_helper.rb