spree_core 5.2.0.rc2 → 5.2.0.rc3
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/jobs/spree/images/save_from_url_job.rb +13 -2
- data/app/models/spree/import_row.rb +1 -0
- data/app/models/spree/import_schemas/products.rb +1 -1
- data/app/models/spree/post.rb +2 -2
- data/app/models/spree/post_category.rb +10 -2
- data/app/models/spree/shipping_rate.rb +7 -3
- data/app/models/spree/store.rb +2 -2
- data/app/presenters/spree/csv/product_variant_presenter.rb +3 -3
- data/app/services/spree/imports/row_processors/product_variant.rb +24 -1
- data/lib/spree/core/configuration.rb +1 -0
- data/lib/spree/core/controller_helpers/order.rb +10 -1
- data/lib/spree/core/importer/order.rb +2 -0
- data/lib/spree/core/importer/product.rb +2 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_factory.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 531657763d76e0ce76fb2845acfeb30c110343666bc5e8e727de1f21249da4cd
|
|
4
|
+
data.tar.gz: 2d4f33f07d6b90d61c9578575889c7c597a39b98e19597c90f902e312832af2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a5aa4b5e32b63a67c2cb557a77014fe1d6cbd55d4f1df437480ff2c3502e4f9fbb533caea745e90a3cb7fd8013439d591f4247c5203e44e75dec638a62abf3e
|
|
7
|
+
data.tar.gz: 7b66c4d564e21310dbc962eb1398886441a0a374b85f955a1e317cdbaef8fb27ea312d1987c33c611138e6ff1bf48e9f4de6a7301f0666423658bf7f831ec0ab
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require 'open-uri'
|
|
2
|
+
require 'openssl'
|
|
2
3
|
|
|
3
4
|
module Spree
|
|
4
5
|
module Images
|
|
5
6
|
class SaveFromUrlJob < ::Spree::BaseJob
|
|
6
7
|
queue_as Spree.queues.images
|
|
7
|
-
retry_on ActiveRecord::RecordInvalid, OpenURI::HTTPError, wait: :polynomially_longer, attempts:
|
|
8
|
+
retry_on ActiveRecord::RecordInvalid, OpenURI::HTTPError, wait: :polynomially_longer, attempts: Spree::Config.images_save_from_url_job_attempts.to_i
|
|
8
9
|
discard_on URI::InvalidURIError
|
|
9
10
|
|
|
10
11
|
def perform(viewable_id, viewable_type, external_url, external_id = nil, position = nil)
|
|
@@ -33,7 +34,17 @@ module Spree
|
|
|
33
34
|
raise URI::InvalidURIError, "Invalid URL scheme: #{uri.scheme}. Only http and https are allowed."
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
file = uri.open
|
|
37
|
+
file = uri.open(
|
|
38
|
+
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
39
|
+
'Accept' => 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
|
|
40
|
+
'Accept-Language' => 'en-US,en;q=0.9',
|
|
41
|
+
'Accept-Encoding' => 'gzip, deflate, br',
|
|
42
|
+
'Cache-Control' => 'no-cache',
|
|
43
|
+
'Pragma' => 'no-cache',
|
|
44
|
+
read_timeout: 60,
|
|
45
|
+
ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER,
|
|
46
|
+
redirect: true
|
|
47
|
+
)
|
|
37
48
|
filename = File.basename(uri.path)
|
|
38
49
|
|
|
39
50
|
image.attachment.attach(io: file, filename: filename)
|
|
@@ -76,6 +76,7 @@ module Spree
|
|
|
76
76
|
self.item = import.row_processor_class.new(self).process!
|
|
77
77
|
complete!
|
|
78
78
|
rescue StandardError => e
|
|
79
|
+
Rails.error.report(e, handled: true, context: { import_row_id: id }, source: 'spree.core')
|
|
79
80
|
self.validation_errors = e.message
|
|
80
81
|
fail!
|
|
81
82
|
end
|
|
@@ -26,7 +26,7 @@ module Spree
|
|
|
26
26
|
{ name: 'inventory_count', label: 'Inventory Count' },
|
|
27
27
|
{ name: 'inventory_backorderable', label: 'Inventory Backorderable' },
|
|
28
28
|
{ name: 'tax_category', label: 'Tax Category' },
|
|
29
|
-
{ name: '
|
|
29
|
+
{ name: 'shipping_category', label: 'Shipping Category' },
|
|
30
30
|
{ name: 'image1_src', label: 'Image 1 URL' },
|
|
31
31
|
{ name: 'image2_src', label: 'Image 2 URL' },
|
|
32
32
|
{ name: 'image3_src', label: 'Image 3 URL' },
|
data/app/models/spree/post.rb
CHANGED
|
@@ -39,8 +39,8 @@ module Spree
|
|
|
39
39
|
# Associations
|
|
40
40
|
#
|
|
41
41
|
belongs_to :author, class_name: Spree.admin_user_class.to_s, optional: true
|
|
42
|
-
belongs_to :store, class_name: 'Spree::Store'
|
|
43
|
-
belongs_to :post_category, class_name: 'Spree::PostCategory', optional: true
|
|
42
|
+
belongs_to :store, class_name: 'Spree::Store', inverse_of: :posts
|
|
43
|
+
belongs_to :post_category, class_name: 'Spree::PostCategory', optional: true, touch: true, inverse_of: :posts
|
|
44
44
|
alias category post_category
|
|
45
45
|
|
|
46
46
|
#
|
|
@@ -9,8 +9,8 @@ module Spree
|
|
|
9
9
|
#
|
|
10
10
|
# Associations
|
|
11
11
|
#
|
|
12
|
-
belongs_to :store, class_name: 'Spree::Store'
|
|
13
|
-
has_many :posts, class_name: 'Spree::Post'
|
|
12
|
+
belongs_to :store, class_name: 'Spree::Store', inverse_of: :post_categories
|
|
13
|
+
has_many :posts, class_name: 'Spree::Post', dependent: :nullify, inverse_of: :post_category
|
|
14
14
|
|
|
15
15
|
#
|
|
16
16
|
# Validations
|
|
@@ -18,8 +18,16 @@ module Spree
|
|
|
18
18
|
validates :title, :store, presence: true
|
|
19
19
|
validates :slug, presence: true, uniqueness: { scope: :store_id }
|
|
20
20
|
|
|
21
|
+
#
|
|
22
|
+
# ActionText
|
|
23
|
+
#
|
|
21
24
|
has_rich_text :description
|
|
22
25
|
|
|
26
|
+
#
|
|
27
|
+
# Ransack
|
|
28
|
+
#
|
|
29
|
+
self.whitelisted_ransackable_attributes = %w[title slug]
|
|
30
|
+
|
|
23
31
|
def should_generate_new_friendly_id?
|
|
24
32
|
slug.blank? || title_changed?
|
|
25
33
|
end
|
|
@@ -7,9 +7,9 @@ module Spree
|
|
|
7
7
|
|
|
8
8
|
money_methods :base_price, :final_price, :tax_amount
|
|
9
9
|
|
|
10
|
-
delegate :order, :currency, :
|
|
11
|
-
delegate :name,
|
|
12
|
-
delegate :code,
|
|
10
|
+
delegate :order, :currency, :with_free_shipping_promotion?, to: :shipment
|
|
11
|
+
delegate :name, to: :shipping_method
|
|
12
|
+
delegate :code, to: :shipping_method, prefix: true
|
|
13
13
|
|
|
14
14
|
def display_price
|
|
15
15
|
price = display_base_price.to_s
|
|
@@ -27,6 +27,10 @@ module Spree
|
|
|
27
27
|
alias display_cost display_price
|
|
28
28
|
alias_attribute :base_price, :cost
|
|
29
29
|
|
|
30
|
+
def free?
|
|
31
|
+
final_price.zero?
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
def tax_amount
|
|
31
35
|
@tax_amount ||= tax_rate&.calculator&.compute_shipping_rate(self) || BigDecimal(0)
|
|
32
36
|
end
|
data/app/models/spree/store.rb
CHANGED
|
@@ -106,8 +106,8 @@ module Spree
|
|
|
106
106
|
has_many :custom_domains, class_name: 'Spree::CustomDomain', dependent: :destroy
|
|
107
107
|
has_one :default_custom_domain, -> { where(default: true) }, class_name: 'Spree::CustomDomain'
|
|
108
108
|
|
|
109
|
-
has_many :posts, class_name: 'Spree::Post'
|
|
110
|
-
has_many :post_categories, class_name: 'Spree::PostCategory'
|
|
109
|
+
has_many :posts, class_name: 'Spree::Post', dependent: :destroy, inverse_of: :store
|
|
110
|
+
has_many :post_categories, class_name: 'Spree::PostCategory', dependent: :destroy, inverse_of: :store
|
|
111
111
|
|
|
112
112
|
has_many :integrations, class_name: 'Spree::Integration'
|
|
113
113
|
|
|
@@ -32,7 +32,7 @@ module Spree
|
|
|
32
32
|
'inventory_count',
|
|
33
33
|
'inventory_backorderable',
|
|
34
34
|
'tax_category',
|
|
35
|
-
'
|
|
35
|
+
'shipping_category',
|
|
36
36
|
'image1_src',
|
|
37
37
|
'image2_src',
|
|
38
38
|
'image3_src',
|
|
@@ -66,7 +66,7 @@ module Spree
|
|
|
66
66
|
# For the primary variant row (when the index is zero), product-level details such as name,
|
|
67
67
|
# slug, status, vendor and brand names, description, meta tags, and tag/label lists are included.
|
|
68
68
|
# In all cases, variant-specific attributes (e.g., id, SKU, pricing, dimensions, weight,
|
|
69
|
-
# availability dates, inventory count,
|
|
69
|
+
# availability dates, inventory count, shipping category, tax category, image URLs via original_url,
|
|
70
70
|
# and the first three option types and corresponding option values) are appended.
|
|
71
71
|
# Additionally, when the index is zero, associated taxons and properties are added.
|
|
72
72
|
#
|
|
@@ -103,7 +103,7 @@ module Spree
|
|
|
103
103
|
total_on_hand == BigDecimal::INFINITY ? '∞' : total_on_hand,
|
|
104
104
|
variant.backorderable?,
|
|
105
105
|
variant.tax_category&.name,
|
|
106
|
-
|
|
106
|
+
product.shipping_category&.name,
|
|
107
107
|
spree_image_url(variant.images[0], image_url_options),
|
|
108
108
|
spree_image_url(variant.images[1], image_url_options),
|
|
109
109
|
spree_image_url(variant.images[2], image_url_options),
|
|
@@ -33,6 +33,12 @@ module Spree
|
|
|
33
33
|
variant.depth = attributes['depth'] if attributes['depth'].present?
|
|
34
34
|
variant.track_inventory = attributes['track_inventory'] if attributes['track_inventory'].present?
|
|
35
35
|
variant.option_value_variants = prepare_option_value_variants
|
|
36
|
+
|
|
37
|
+
if attributes['tax_category'].present?
|
|
38
|
+
tax_category = prepare_tax_category
|
|
39
|
+
variant.tax_category = tax_category if tax_category.present?
|
|
40
|
+
end
|
|
41
|
+
|
|
36
42
|
variant.save!
|
|
37
43
|
|
|
38
44
|
if attributes['price'].present?
|
|
@@ -94,10 +100,27 @@ module Spree
|
|
|
94
100
|
product.status = to_spree_status(attributes['status']) if attributes['status'].present?
|
|
95
101
|
product.tag_list = attributes['tags'] if attributes['tags'].present?
|
|
96
102
|
|
|
97
|
-
|
|
103
|
+
if options.empty?
|
|
104
|
+
if attributes['shipping_category'].present?
|
|
105
|
+
shipping_category = prepare_shipping_category
|
|
106
|
+
product.shipping_category = shipping_category if shipping_category.present?
|
|
107
|
+
end
|
|
108
|
+
product.taxons = prepare_taxons
|
|
109
|
+
end
|
|
110
|
+
|
|
98
111
|
product
|
|
99
112
|
end
|
|
100
113
|
|
|
114
|
+
def prepare_shipping_category
|
|
115
|
+
shipping_category_name = attributes['shipping_category'].strip
|
|
116
|
+
Spree::ShippingCategory.find_by(name: shipping_category_name)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def prepare_tax_category
|
|
120
|
+
tax_category_name = attributes['tax_category'].strip
|
|
121
|
+
Spree::TaxCategory.find_by(name: tax_category_name)
|
|
122
|
+
end
|
|
123
|
+
|
|
101
124
|
def prepare_taxons
|
|
102
125
|
taxon_pretty_names = [
|
|
103
126
|
attributes['category1'],
|
|
@@ -45,6 +45,7 @@ module Spree
|
|
|
45
45
|
preference :expedited_exchanges, :boolean, default: false # NOTE this requires payment profiles to be supported on your gateway of choice as well as a delayed job handler to be configured with activejob. kicks off an exchange shipment upon return authorization save. charge customer if they do not return items within timely manner.
|
|
46
46
|
preference :expedited_exchanges_days_window, :integer, default: 14 # the amount of days the customer has to return their item after the expedited exchange is shipped in order to avoid being charged
|
|
47
47
|
preference :geocode_addresses, :boolean, default: true
|
|
48
|
+
preference :images_save_from_url_job_attempts, :integer, default: 5
|
|
48
49
|
preference :layout, :string, deprecated: 'Please use Spree::Frontend::Config[:layout] instead'
|
|
49
50
|
preference :logo, :string, deprecated: true
|
|
50
51
|
preference :mailer_logo, :string, deprecated: true
|
|
@@ -118,11 +118,20 @@ module Spree
|
|
|
118
118
|
value: token,
|
|
119
119
|
expires: 90.days.from_now,
|
|
120
120
|
secure: Rails.configuration.force_ssl || Rails.application.config.ssl_options[:secure_cookies],
|
|
121
|
-
domain:
|
|
121
|
+
domain: cookie_domain_without_port,
|
|
122
122
|
httponly: true
|
|
123
123
|
}
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
+
def cookie_domain_without_port
|
|
127
|
+
domain = current_store.url_or_custom_domain
|
|
128
|
+
return nil if domain.blank?
|
|
129
|
+
|
|
130
|
+
# Remove port from domain (e.g., "localhost:3000" -> "localhost")
|
|
131
|
+
# Cookies don't support port numbers in the domain attribute
|
|
132
|
+
domain.split(':').first
|
|
133
|
+
end
|
|
134
|
+
|
|
126
135
|
def last_incomplete_order(includes = {})
|
|
127
136
|
@last_incomplete_order ||= try_spree_current_user.last_incomplete_spree_order(current_store, includes: includes)
|
|
128
137
|
end
|
|
@@ -3,6 +3,8 @@ module Spree
|
|
|
3
3
|
module Importer
|
|
4
4
|
class Order
|
|
5
5
|
def self.import(user, params)
|
|
6
|
+
Spree::Deprecation.warn('Spree::Core::Importer::Order is deprecated and will be removed in Spree 6.0. Please use `Spree::Imports::Order` instead.')
|
|
7
|
+
|
|
6
8
|
ensure_country_id_from_params params[:ship_address_attributes]
|
|
7
9
|
ensure_state_id_from_params params[:ship_address_attributes]
|
|
8
10
|
ensure_country_id_from_params params[:bill_address_attributes]
|
|
@@ -5,6 +5,8 @@ module Spree
|
|
|
5
5
|
attr_reader :product, :product_attrs, :variants_attrs, :options_attrs, :store
|
|
6
6
|
|
|
7
7
|
def initialize(product, product_params, options = {})
|
|
8
|
+
Spree::Deprecation.warn('Spree::Core::Importer::Product is deprecated and will be removed in Spree 6.0. Please use `Spree::Imports::Product` instead.')
|
|
9
|
+
|
|
8
10
|
@store = options[:store] || Spree::Store.default
|
|
9
11
|
@product = product || Spree::Product.new(product_params)
|
|
10
12
|
@product.stores << @store if @product.stores.exclude?(@store)
|
data/lib/spree/core/version.rb
CHANGED
|
@@ -11,11 +11,11 @@ FactoryBot.define do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
factory :shipping_calculator, class: Spree::Calculator::Shipping::FlatRate do
|
|
14
|
-
|
|
14
|
+
preferred_amount { 10.0 }
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
factory :shipping_no_amount_calculator, class: Spree::Calculator::Shipping::FlatRate do
|
|
18
|
-
|
|
18
|
+
preferred_amount { 0 }
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
factory :flat_rate_calculator, class: Spree::Calculator::FlatRate do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.2.0.
|
|
4
|
+
version: 5.2.0.rc3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Schofield
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2025-11-
|
|
13
|
+
date: 2025-11-18 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: i18n-tasks
|
|
@@ -1656,9 +1656,9 @@ licenses:
|
|
|
1656
1656
|
- BSD-3-Clause
|
|
1657
1657
|
metadata:
|
|
1658
1658
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
1659
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v5.2.0.
|
|
1659
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v5.2.0.rc3
|
|
1660
1660
|
documentation_uri: https://docs.spreecommerce.org/
|
|
1661
|
-
source_code_uri: https://github.com/spree/spree/tree/v5.2.0.
|
|
1661
|
+
source_code_uri: https://github.com/spree/spree/tree/v5.2.0.rc3
|
|
1662
1662
|
post_install_message:
|
|
1663
1663
|
rdoc_options: []
|
|
1664
1664
|
require_paths:
|