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.

Update weight.rb sorting

Ricardo Trindade09209eade03e
diff --git a/core/app/models/spree/stock/splitter/weight.rb b/core/app/models/spree/stock/splitter/weight.rb
index 0e5dbeb49d..7fdc051606 100644
--- a/core/app/models/spree/stock/splitter/weight.rb
+++ b/core/app/models/spree/stock/splitter/weight.rb
@@ -15,7 +15,7 @@ module Spree
private
def reduce(package)
- contents = split_package_contents_over_threshold(package).sort { |x, y| y.weight <=> x.weight }
+ contents = split_package_contents_over_threshold(package).sort_by(&:weight).reverse
# Treat current package as one of the generated packages for convenience and add the heaviest item
# This also prevents an additional package if no fit is possible
package.contents.clear