solidus_promotions 4.4.1 → 4.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/solidus_promotions/order_adjuster.rb +1 -1
- data/app/models/solidus_promotions/promotion.rb +11 -1
- data/app/models/solidus_promotions/promotion_handler/coupon.rb +4 -0
- data/lib/components/admin/solidus_promotions/promotions/index/component.rb +6 -4
- data/lib/components/admin/solidus_promotions/promotions/index/component.yml +1 -0
- data/lib/controllers/admin/solidus_promotions/promotion_categories_controller.rb +6 -0
- data/lib/controllers/admin/solidus_promotions/promotions_controller.rb +4 -0
- data/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb +4 -4
- data/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb +4 -0
- data/solidus_promotions.gemspec +2 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c806b16cf91750622bd6577afe715ac790b156131f78111827f6fd357cd3fcb
|
4
|
+
data.tar.gz: 35a5c2ec0bbf7d6edb53b1322da77c4128336ae805d94c4579e9e40e25ad574b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a470f82057f41699defd90c694caba8c525ff7d54b0672c0f1ea27b5bf9786512b6b2f87b4d0f4f9c326c7e0a8b2bf6c6a4660589285f58509ff67c2d6e7030
|
7
|
+
data.tar.gz: 74f76a2e69d156e4104dd80934867fa96fac155df112c5799309e715475f9be5a6f4ca92d2aac49d4aecc6acd0fd06eaacc3cf9113ab103be8225a7e666c74e2
|
@@ -13,7 +13,7 @@ module SolidusPromotions
|
|
13
13
|
def call
|
14
14
|
order.reset_current_discounts
|
15
15
|
|
16
|
-
return order
|
16
|
+
return order unless SolidusPromotions::Promotion.order_activatable?(order)
|
17
17
|
|
18
18
|
discounted_order = DiscountOrder.new(order, promotions, dry_run: dry_run).call
|
19
19
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module SolidusPromotions
|
4
4
|
class Promotion < Spree::Base
|
5
|
+
UNACTIVATABLE_ORDER_STATES = ["awaiting_return", "returned", "canceled"]
|
6
|
+
|
5
7
|
include Spree::SoftDeletable
|
6
8
|
|
7
9
|
belongs_to :category, class_name: "SolidusPromotions::PromotionCategory",
|
@@ -9,7 +11,7 @@ module SolidusPromotions
|
|
9
11
|
belongs_to :original_promotion, class_name: "Spree::Promotion", optional: true
|
10
12
|
has_many :benefits, class_name: "SolidusPromotions::Benefit", dependent: :destroy
|
11
13
|
has_many :conditions, through: :benefits
|
12
|
-
has_many :codes, class_name: "SolidusPromotions::PromotionCode", dependent: :destroy
|
14
|
+
has_many :codes, class_name: "SolidusPromotions::PromotionCode", dependent: :destroy, inverse_of: :promotion
|
13
15
|
has_many :code_batches, class_name: "SolidusPromotions::PromotionCodeBatch", dependent: :destroy
|
14
16
|
has_many :order_promotions, class_name: "SolidusPromotions::OrderPromotion", dependent: :destroy
|
15
17
|
|
@@ -59,6 +61,14 @@ module SolidusPromotions
|
|
59
61
|
lanes.sort_by(&:last).to_h
|
60
62
|
end
|
61
63
|
|
64
|
+
def self.order_activatable?(order)
|
65
|
+
return false if UNACTIVATABLE_ORDER_STATES.include?(order.state)
|
66
|
+
return false if order.shipped?
|
67
|
+
return false if order.complete? && !SolidusPromotions.config.recalculate_complete_orders
|
68
|
+
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
62
72
|
self.allowed_ransackable_associations = ["codes"]
|
63
73
|
self.allowed_ransackable_attributes = %w[name customer_label path promotion_category_id lane updated_at]
|
64
74
|
self.allowed_ransackable_scopes = %i[active with_discarded]
|
@@ -14,7 +14,7 @@ class SolidusPromotions::Promotions::Index::Component < SolidusAdmin::UI::Pages:
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def row_url(promotion)
|
17
|
-
solidus_promotions.
|
17
|
+
solidus_promotions.edit_admin_promotion_path(promotion)
|
18
18
|
end
|
19
19
|
|
20
20
|
def page_actions
|
@@ -63,14 +63,16 @@ class SolidusPromotions::Promotions::Index::Component < SolidusAdmin::UI::Pages:
|
|
63
63
|
{
|
64
64
|
header: :name,
|
65
65
|
data: ->(promotion) do
|
66
|
-
|
66
|
+
link_to promotion.name, row_url(promotion)
|
67
67
|
end
|
68
68
|
},
|
69
69
|
{
|
70
70
|
header: :code,
|
71
71
|
data: ->(promotion) do
|
72
|
-
|
73
|
-
|
72
|
+
link_to solidus_promotions.admin_promotion_promotion_codes_path(promotion), title: t(".codes") do
|
73
|
+
count = promotion.codes.count
|
74
|
+
(count == 1) ? promotion.codes.pick(:value) : t("spree.number_of_codes", count: count)
|
75
|
+
end
|
74
76
|
end
|
75
77
|
},
|
76
78
|
{
|
@@ -25,5 +25,11 @@ module SolidusPromotions
|
|
25
25
|
flash[:notice] = t(".success")
|
26
26
|
redirect_back_or_to solidus_promotions.promotion_categories_path, status: :see_other
|
27
27
|
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def authorization_subject
|
32
|
+
SolidusPromotions::PromotionCategory
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
@@ -14,12 +14,12 @@ module SolidusPromotions
|
|
14
14
|
def create
|
15
15
|
@benefit = @benefit_type.new(benefit_params)
|
16
16
|
@benefit.promotion = @promotion
|
17
|
-
if @benefit.save
|
17
|
+
if @benefit.save
|
18
18
|
flash[:success] =
|
19
19
|
t("spree.successfully_created", resource: SolidusPromotions::Benefit.model_name.human)
|
20
20
|
redirect_to location_after_save, format: :html
|
21
21
|
else
|
22
|
-
render :new, layout: false
|
22
|
+
render :new, layout: false, status: :unprocessable_entity
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -28,7 +28,7 @@ module SolidusPromotions
|
|
28
28
|
if params.dig(:benefit, :calculator_type)
|
29
29
|
@benefit.calculator_type = params[:benefit][:calculator_type]
|
30
30
|
end
|
31
|
-
render layout: false
|
31
|
+
render layout: false, status: :unprocessable_entity
|
32
32
|
end
|
33
33
|
|
34
34
|
def update
|
@@ -39,7 +39,7 @@ module SolidusPromotions
|
|
39
39
|
t("spree.successfully_updated", resource: SolidusPromotions::Benefit.model_name.human)
|
40
40
|
redirect_to location_after_save, format: :html
|
41
41
|
else
|
42
|
-
render :edit
|
42
|
+
render :edit, status: :unprocessable_entity
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/solidus_promotions.gemspec
CHANGED
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
25
25
|
spec.files = files.grep_v(%r{^(spec|bin)/})
|
26
26
|
|
27
|
+
spec.add_development_dependency "solidus_legacy_promotions"
|
28
|
+
|
27
29
|
spec.add_dependency "importmap-rails", "~> 1.2"
|
28
30
|
spec.add_dependency "ransack-enum", "~> 1.0"
|
29
31
|
spec.add_dependency "solidus_core", [">= 4.0.0", "< 5"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_promotions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Meyerhoff
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: solidus_legacy_promotions
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: importmap-rails
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -358,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
372
|
- !ruby/object:Gem::Version
|
359
373
|
version: '0'
|
360
374
|
requirements: []
|
361
|
-
rubygems_version: 3.5.
|
375
|
+
rubygems_version: 3.5.3
|
362
376
|
signing_key:
|
363
377
|
specification_version: 4
|
364
378
|
summary: New promotion system for Solidus
|