spree_core 5.1.0 → 5.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10a63ea31ea45db426f45aa13fb90de77dac8ab0a024f7812562aed34991b9e8
4
- data.tar.gz: 2ca5104581c280ce3b1328e52bfd8988971012feb01287174b4afa3ea494917c
3
+ metadata.gz: 7d8a34e50f4423209d4f31a31ef6c40055c0257c83ee28d41655bd0a6c004f83
4
+ data.tar.gz: 49a23607e20571089a6443447413ea236f02bd5d92518de83ddd334d859b18b8
5
5
  SHA512:
6
- metadata.gz: f23f420db0bcced89590044a3b101754c934b06bc882adbe288163ef9b46166e829f79c824ad3eb83329ed8b6eb4e03aefcac8d1e5783eec42e7ba00ceb59dcb
7
- data.tar.gz: d6c770cd94212ca2f919a62eeafc5bc58cc1440da8c3f98c9c6421c20fd12188995e0f93662225d0fb91d7afe769ae5488fc4b34360aeaa5fec2443e14216a49
6
+ metadata.gz: 3e85f284aeb474a1b25d9b4c9d0f15bfae581cab26a06e7433c74bc54756e837e079eab6aca88f9e895a1f36baee7ab12b6069a839a8c3a006cef5b29f94f02b
7
+ data.tar.gz: b10269230a1ca074f7de2bc16a31aa7fdd58e858d6e5ae7fd143884e72f67a0b8b4e04754effbfde836ff91763fbc082c5f74311d842f06e550dddc76ffa69b5
@@ -1,5 +1,9 @@
1
1
  module Spree
2
2
  module BaseHelper
3
+ def spree_dom_id(record)
4
+ dom_id(record, 'spree')
5
+ end
6
+
3
7
  def available_countries
4
8
  countries = current_store.countries_available_for_checkout
5
9
 
@@ -9,7 +9,7 @@ module Spree
9
9
  # @option options [Integer] :height the height of the image
10
10
  def spree_image_tag(image, options = {})
11
11
  image_tag(
12
- spree_image_url(image, { width: options[:width], height: options[:height] }),
12
+ spree_image_url(image, { width: options[:width], height: options[:height], format: options[:format] }),
13
13
  options
14
14
  )
15
15
  end
@@ -18,7 +18,6 @@ module Spree
18
18
  return unless image
19
19
  return unless image.variable?
20
20
  return if image.respond_to?(:attached?) && !image.attached?
21
-
22
21
  url_helpers = respond_to?(:main_app) ? main_app : Rails.application.routes.url_helpers
23
22
  width = options[:width]
24
23
  height = options[:height]
@@ -28,11 +27,11 @@ module Spree
28
27
 
29
28
  if width.present? && height.present?
30
29
  url_helpers.cdn_image_url(
31
- image.variant(spree_image_variant_options(resize_to_fill: [width, height]))
30
+ image.variant(spree_image_variant_options(resize_to_fill: [width, height], format: options[:format]))
32
31
  )
33
32
  else
34
33
  url_helpers.cdn_image_url(
35
- image.variant(spree_image_variant_options(resize_to_limit: [width, height]))
34
+ image.variant(spree_image_variant_options(resize_to_limit: [width, height], format: options[:format]))
36
35
  )
37
36
  end
38
37
  end
@@ -77,16 +76,30 @@ module Spree
77
76
  # @option options [Integer] :height the height of the image
78
77
  def spree_image_variant_options(options = {})
79
78
  {
80
- saver: {
81
- strip: true,
82
- quality: 75,
83
- lossless: false,
84
- alpha_q: 85,
85
- reduction_effort: 6,
86
- smart_subsample: true
87
- },
88
- format: :webp
89
- }.merge(options)
79
+ saver: options[:format] == :png ? png_variant_options : webp_variant_options,
80
+ format: options[:format] || :webp
81
+ }.merge(options.except(:format))
82
+ end
83
+
84
+ private
85
+
86
+ def webp_variant_options
87
+ {
88
+ strip: true,
89
+ quality: 75,
90
+ lossless: false,
91
+ alpha_q: 85,
92
+ reduction_effort: 6,
93
+ smart_subsample: true
94
+ }
95
+ end
96
+
97
+ def png_variant_options
98
+ {
99
+ strip: true,
100
+ compression_level: 8,
101
+ interlace: true
102
+ }
90
103
  end
91
104
  end
92
105
  end
@@ -5,7 +5,7 @@ module Spree
5
5
 
6
6
  def variant_image_url(variant)
7
7
  image = variant.default_image
8
- image.present? && image.attached? ? spree_image_url(image, width: 100, height: 100) : image_url('noimage/small.png')
8
+ image.present? && image.attached? ? spree_image_url(image, width: 100, height: 100, format: :png) : image_url('noimage/small.png')
9
9
  end
10
10
 
11
11
  def name_for(order)
@@ -110,7 +110,7 @@ module Spree
110
110
  before_transition to: :delivery, do: :create_shipment_tax_charge!
111
111
  before_transition from: :delivery, do: :apply_free_shipping_promotions
112
112
  before_transition to: :delivery, do: :apply_unassigned_promotions
113
- after_transition to: :delivery, do: :go_to_payment_if_fully_digital!
113
+ after_transition to: :delivery, do: :move_to_next_step_if_address_not_required
114
114
  end
115
115
 
116
116
  before_transition to: :resumed, do: :ensure_line_item_variants_are_not_discontinued
@@ -298,6 +298,12 @@ module Spree
298
298
  user && user.default_credit_card.try(:valid?)
299
299
  end
300
300
 
301
+ def move_to_next_step_if_address_not_required
302
+ return if requires_ship_address?
303
+
304
+ next!
305
+ end
306
+
301
307
  private
302
308
 
303
309
  # For payment step, filter order parameters to produce the expected nested
@@ -32,13 +32,6 @@ module Spree
32
32
  end
33
33
  end
34
34
  end
35
-
36
- def go_to_payment_if_fully_digital!
37
- return unless digital?
38
- return unless delivery?
39
-
40
- next!
41
- end
42
35
  end
43
36
  end
44
37
  end
@@ -46,7 +46,7 @@ module Spree
46
46
  'archived' => 'archived'
47
47
  }.freeze
48
48
 
49
- TRANSLATABLE_FIELDS = %i[name description slug meta_description meta_keywords meta_title].freeze
49
+ TRANSLATABLE_FIELDS = %i[name description slug meta_description meta_title].freeze
50
50
  translates(*TRANSLATABLE_FIELDS, column_fallback: !Spree.always_use_translations?)
51
51
 
52
52
  self::Translation.class_eval do
@@ -251,7 +251,7 @@ module Spree
251
251
  delegate method_name, :"#{method_name}=", to: :default_variant
252
252
  end
253
253
 
254
- delegate :display_amount, :display_price, :has_default_price?,
254
+ delegate :display_amount, :display_price, :has_default_price?, :track_inventory?,
255
255
  :display_compare_at_price, :images, to: :default_variant
256
256
 
257
257
  delegate :name, to: :brand, prefix: true, allow_nil: true
@@ -1,5 +1,7 @@
1
1
  module Spree
2
2
  class ShippingCategory < Spree.base_class
3
+ DIGITAL_NAME = 'Digital'
4
+
3
5
  include Spree::UniqueName
4
6
  if defined?(Spree::Webhooks::HasWebhooks)
5
7
  include Spree::Webhooks::HasWebhooks
@@ -10,5 +12,9 @@ module Spree
10
12
  has_many :shipping_method_categories
11
13
  end
12
14
  has_many :shipping_methods, through: :shipping_method_categories
15
+
16
+ def self.digital
17
+ find_by(name: DIGITAL_NAME)
18
+ end
13
19
  end
14
20
  end
@@ -25,8 +25,8 @@ module Spree
25
25
  # Translations
26
26
  #
27
27
  TRANSLATABLE_FIELDS = %i[name meta_description meta_keywords seo_title facebook
28
- twitter instagram customer_support_email description
29
- address contact_phone new_order_notifications_email].freeze
28
+ twitter instagram customer_support_email
29
+ address contact_phone].freeze
30
30
  translates(*TRANSLATABLE_FIELDS, column_fallback: !Spree.always_use_translations?)
31
31
  self::Translation.class_eval do
32
32
  acts_as_paranoid
@@ -74,7 +74,7 @@ module Spree
74
74
  after_create :set_master_out_of_stock, unless: :is_master?
75
75
  after_commit :clear_line_items_cache, on: :update
76
76
 
77
- after_create :create_default_stock_item, unless: :track_inventory?
77
+ after_save :create_default_stock_item, unless: :track_inventory?
78
78
  after_update_commit :handle_track_inventory_change
79
79
 
80
80
  after_commit :remove_prices_from_master_variant, on: [:create, :update], unless: :is_master?
@@ -23,7 +23,7 @@
23
23
  <% elsif payment_method_icon_tag(payment.payment_method.payment_icon_name).present? %>
24
24
  <div class="d-flex flex align-items-center items-center">
25
25
  <div><%= payment_method_icon_tag(payment.payment_method.payment_icon_name) %></div>
26
- <div class="mx-2"><%= Spree.t(:store_credit_name) %></div>
26
+ <div class="ml-3"><%= Spree.t(:store_credit_name) %></div>
27
27
  </div>
28
28
  <% end %>
29
29
  <% elsif source.present? %>
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '5.1.0'.freeze
2
+ VERSION = '5.1.1'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -53,6 +53,11 @@ FactoryBot.define do
53
53
  create(:product_property, product: product, property_id: 10, value: 'Epsilon')
54
54
  end
55
55
  end
56
+
57
+ factory :digital_product do
58
+ track_inventory { false }
59
+ shipping_category { |r| Spree::ShippingCategory.digital || r.association(:digital_shipping_category) }
60
+ end
56
61
  end
57
62
  end
58
63
  end
@@ -2,4 +2,8 @@ FactoryBot.define do
2
2
  factory :shipping_category, class: Spree::ShippingCategory do
3
3
  sequence(:name) { |n| "ShippingCategory #{n}" }
4
4
  end
5
+
6
+ factory :digital_shipping_category, class: Spree::ShippingCategory do
7
+ name { 'Digital' }
8
+ end
5
9
  end
@@ -24,7 +24,7 @@ FactoryBot.define do
24
24
 
25
25
  before(:create) do |shipping_method|
26
26
  shipping_method.shipping_categories.delete_all
27
- shipping_method.shipping_categories << create(:shipping_category, name: 'Digital')
27
+ shipping_method.shipping_categories << create(:digital_shipping_category)
28
28
  end
29
29
  end
30
30
  end
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.1.0
4
+ version: 5.1.1
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-07-03 00:00:00.000000000 Z
13
+ date: 2025-07-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n-tasks
@@ -1382,9 +1382,9 @@ licenses:
1382
1382
  - BSD-3-Clause
1383
1383
  metadata:
1384
1384
  bug_tracker_uri: https://github.com/spree/spree/issues
1385
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.1.0
1385
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.1.1
1386
1386
  documentation_uri: https://docs.spreecommerce.org/
1387
- source_code_uri: https://github.com/spree/spree/tree/v5.1.0
1387
+ source_code_uri: https://github.com/spree/spree/tree/v5.1.1
1388
1388
  post_install_message:
1389
1389
  rdoc_options: []
1390
1390
  require_paths: