Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Replace `Float::INFINITY` with `BigDecimal::INFINITY` (#11588)

Damian Legawiec6c57940b4e75
diff --git a/core/app/finders/spree/products/find.rb b/core/app/finders/spree/products/find.rb
index d9e5a8417b..53309b0743 100644
--- a/core/app/finders/spree/products/find.rb
+++ b/core/app/finders/spree/products/find.rb
@@ -257,7 +257,7 @@ module Spree
def map_prices(prices)
prices.map do |price|
- price == 'Infinity' ? Float::INFINITY : price.to_f
+ price == 'Infinity' ? BigDecimal::INFINITY : price.to_f
end
end
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb
index 853e731f97..7e4dd4e232 100644
--- a/core/app/models/spree/product.rb
+++ b/core/app/models/spree/product.rb
@@ -302,7 +302,7 @@ module Spree
def total_on_hand
@total_on_hand ||= Rails.cache.fetch(['product-total-on-hand', cache_key_with_version]) do
if any_variants_not_track_inventory?
- Float::INFINITY
+ BigDecimal::INFINITY
else
stock_items.sum(:count_on_hand)
end
@@ -338,6 +338,10 @@ module Spree
end
end
+ def digital?
+ shipping_category == I18n.t('spree.seed.shipping.categories.digital')
+ end
+
private
def add_associations_from_prototype
diff --git a/core/app/models/spree/stock/quantifier.rb b/core/app/models/spree/stock/quantifier.rb
index 69941c7cff..06a01770c7 100644
--- a/core/app/models/spree/stock/quantifier.rb
+++ b/core/app/models/spree/stock/quantifier.rb
@@ -12,7 +12,7 @@ module Spree
@total_on_hand ||= if variant.should_track_inventory?
stock_items.sum(:count_on_hand)
else
- Float::INFINITY
+ BigDecimal::INFINITY
end
end
diff --git a/core/lib/spree/core/search/base.rb b/core/lib/spree/core/search/base.rb
index 62ba3645d5..2f3c1bb3de 100644
--- a/core/lib/spree/core/search/base.rb
+++ b/core/lib/spree/core/search/base.rb
@@ -101,7 +101,7 @@ module Spree
high_price = Monetize.parse(price_param.remove("#{less_than_string} ")).to_i
else
low_price, high_price = Monetize.parse_collection(price_param).map(&:to_i)
- high_price = Float::INFINITY if high_price&.zero?
+ high_price = BigDecimal::INFINITY if high_price&.zero?
end
"#{low_price},#{high_price}"