4

In spree commerce is there any way to get the stock location of the line items.

Ranjith
  • 145
  • 6

1 Answers1

3

Firstly You can find you complete order let say you order number is R001023223 Then

order = Spree::Order.complete.find_by_number('R001023223')

then find line item as like this

For single line item stock location

line_item = order.line_items.first
stock_locations = line_item.variant.stock_locations

For all stock locations of line items:

stock_locations = order.variants.map(&:stock_locations).flatten

that's it...!!!

Vishal JAIN
  • 1,940
  • 1
  • 11
  • 14
milind phirake
  • 493
  • 3
  • 8