spree-contrib/spree-product-assembly

Spree 4.2

jhovad opened this issue · 1 comments

Are you going to update it for Spree 4.2? There are some very small glitches in admin, but mainly "Add to cart" is not working. :(

I finally implemented my own solution, anyway for there are my points for necessary updates to Spree 4.2 compatibility:

https://github.com/spree/spree/blob/c47e591882d79e766847c627773d29186aa2224b/frontend/app/assets/javascripts/spree/frontend/views/spree/products/cart_form.js#L283
-> this pass empty param[:options]… JavaScript have to be customized for passing selected variant of the part (update of the part variant selector form to 4.2 style would be also nice)

===========

options[:selected_variants]['selected_variants'][part.part.id.to_s]

-> double of [:selected_variants]['selected_variants’] … should be only [:selected_variants]

===========

Maybe Spree issue, if not then create decorator …:
spree/spree#10986

===========

def build_inventory_unit(variant, line_item, quantity=nil)

-> outdated implementation that doubles InventoryUnits … should be maybe like

module Spree
  module Stock
    module InventoryUnitBuilderDecorator
      def units
        @order.line_items.flat_map do |line_item|
          line_item.quantity_by_variant.flat_map do |variant, quantity|
            byebug
            Spree::InventoryUnit.new(
              pending: true,
              line_item_id: line_item.id,
              variant_id: variant.id,
              quantity: quantity,
              order_id: @order.id,
            )
          end
        end
      end
    end
  end
end

… maybe another issues, but this was what I noticed