-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorreclty splits packages #1417
Incorreclty splits packages #1417
Conversation
@@ -205,14 +219,29 @@ | |||
end | |||
|
|||
context "update cart" do | |||
let!(:shirt) { subject.add variant, 1 } | |||
let!(:shirt) { subject.add variant, 1 , stock_location_quantities: { stock_location.id => 1} } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space found before comma.
Space inside } missing.
4278fbc
to
5a301f7
Compare
end | ||
end | ||
|
||
def correct_order_stock_location_quantity(line_item, stock_location_quantities, &block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.
5a301f7
to
7f65ceb
Compare
options = { | ||
variant_stock_location_quantities: { | ||
@line_item.variant_id => { | ||
@line_item.variant.stock_locations.first.id => 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this right? should it be first.id: 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, i push the changes
Add an options param to update_cart method to update order_stock_location. The options param require the follow format: ``` { variant_stock_location_quantities: { shirt.variant_id => { stock_location.id => 3 } } } ``` Now when method `add` is call with same variant and stock_location, the `order_stock_location` quantity is updated. Pass the formatted params to `update_cart` for update order_stock_location.
7f65ceb
to
9728e20
Compare
This is tricky Traditionally stock locations aren't associated until the packaging step. This allows for some "intelligent" packaging and allows stock to be drawn from whichever stock location has inventory available. This is the most common path that any frontend store will do, and is probably what out backend should do most of the time. This changed with the introduction of the OrderStockLocation (which was not a particularly complete implementation IMNSHO). An OrderStockLocation ties some amount of a variant to a particular stock location. When packaging, it builds these as separate shipments. We run into issues because under different circumstances our banckend behaves differently w/r/t adding an I'm don't think adding an |
Hi @jhawthorn , i understand what do you mean, i agree with you probably it's better clarify to the admin user the stock status and how the stock items in the order are splitted. I propose to change the update quantity logic and give the possibility to change the quantity for each stock item. I drew a mockup to show you how i want implement this. In order cart page with one item added in order, the user click on The admin show the The admin can change specific quantity for each What do you think about it? |
@DanielePalombo this needs a rebase with master. |
Before rebase or other changes, I'm waiting to know if my proposed solution can be alright. |
Was about to mention that Daniele after I read the rest of this thread! 👍 |
@DanielePalombo sorry for the delay. In addition to being assigned to a specific stock location, the default is that the variant can come from any stock location. IMO whatever UI we come up with should favour this default, since most of the that's probably what an admin would want. |
Sorry I don't understand what do you mean. |
This should be fixed by #1709, which bypasses the "location configured package" feature, which is what caused the separate shipments |
rel #1366
After investigation i see that the
order_stock_location
isn't update whenupdate_cart
is call (https://github.com/solidusio/solidus/blob/master/core/app/models/spree/order_contents.rb#L37-L67), and theorder_stock_location
creation is skipped if line_item isn't a new record(https://github.com/solidusio/solidus/blob/master/core/app/models/spree/order_contents.rb#L146).solution to bug 1:
Update the quantity of
order_stock_location
when theupdate_cart
method is called.solution to bug 2:
Update the quantity of
order_stock_location
when an item is add to cart if already present an othervariant
andstock_location
in the cart