From d39468013e727fa37d551bdf9c39a7cf8f593266 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 30 Jan 2021 16:51:46 +0000 Subject: [PATCH 1/2] Clarify CartService#populate arguments This method doesn't use :products anywhere, it doesn't need to be passed in as part of the argument. --- app/controllers/cart_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/cart_controller.rb b/app/controllers/cart_controller.rb index 4be930cc12..658ef2e2f5 100644 --- a/app/controllers/cart_controller.rb +++ b/app/controllers/cart_controller.rb @@ -11,7 +11,7 @@ class CartController < BaseController Spree::Adjustment.without_callbacks do cart_service = CartService.new(order) - cart_service.populate(params.slice(:products, :variants, :quantity), true) + cart_service.populate(params.slice(:variants, :quantity), true) if cart_service.valid? order.update_distribution_charge! order.cap_quantity_at_stock! From 3da21ce2bdf8914c244eb09a7a1b33a3740dc644 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 30 Jan 2021 16:57:05 +0000 Subject: [PATCH 2/2] Add historical note to CartService Useful background when applying upstream fixes from Spree::OrderPopulator, and means grepping for OrderPopulator doesn't come up empty. --- app/services/cart_service.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/cart_service.rb b/app/services/cart_service.rb index cecde9deec..35dcb720f0 100644 --- a/app/services/cart_service.rb +++ b/app/services/cart_service.rb @@ -1,5 +1,7 @@ require 'open_food_network/scope_variant_to_hub' +# Previously Spree::OrderPopulator. Modified to work with max_quantity and variant overrides. + class CartService attr_accessor :order, :currency attr_reader :variants_h