undefined method on_hand for class Spree::Product
Closed this issue · 4 comments
futhr commented
This is for the master branch.
undefined method on_hand
for class Spree::Product
/bundler/gems/spree-product-assembly-9910a841ae06/app/models/spree/product_decorator.rb:28:in `block in <top (required)>'
/bundler/gems/spree-product-assembly-9910a841ae06/app/models/spree/product_decorator.rb:1:in `class_eval'
/bundler/gems/spree-product-assembly-9910a841ae06/app/models/spree/product_decorator.rb:1:in `<top (required)>'
radar commented
This would be due to the shipping changes that landed on the master branch in Spree this week. I don't know much about the internals of the spree-product-assembly gem, but it looks like these methods inside the product_decorator
need to be changed:
# returns the number of inventory units "on_hand" for this product
def on_hand_with_assembly(reload = false)
if self.assembly? && Spree::Config[:track_inventory_levels]
parts(reload).map{|v| v.on_hand / self.count_of(v) }.min
else
on_hand_without_assembly
end
end
alias_method_chain :on_hand, :assembly
alias_method :orig_on_hand=, :on_hand=
def on_hand=(new_level)
self.orig_on_hand=(new_level) unless self.assembly?
end
alias_method :orig_has_stock?, :has_stock?
def has_stock?
if self.assembly? && Spree::Config[:track_inventory_levels]
!parts.detect{|v| self.count_of(v) > v.on_hand}
else
self.orig_has_stock?
end
end
nonfungibletunji commented
any update or workarounds. or are u waiting until the dust settles some more :)
huoxito commented
This has been fixed in master. Please take a look and let me know if you still run into issues.