-
Notifications
You must be signed in to change notification settings - Fork 0
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
[API for shopfronts] Refactor OFN shop list to use API for add line items to cart #199
Comments
Excellent, @luisramos0, that's exactly what we discussed. Looking at it now, I'm just wondering if it's too much in one step. Maybe we can break it into smaller pull requests.
What do you think? |
Yes, agree, excellent. Before I start changing things I am documenting my study of the code here: The controllers structure is quite amusing!!! |
The PR with the first change is openfoodfoundation/openfoodnetwork#2542, it's ready for review. |
Hey @mkllnk , after evaluating what to do next, these are my conclusions: I understand that refactoring of the /cart/populate endpoint: Instead of having the UI sending the full list of variants in the cart, we would have the UI send individual variants to be added to the order using a new API endpoint. We could do this and it would be good. There are other things we could do, for example, move the cart page (orders#edit and orders#update, both controllers and views) to become completely independent of spree code. It would not be too difficult to do and it would be a very good improvement. But the main conclusion is: these improvements are not necessary for the spree upgrade. For the spree upgrade, all we need is to review the order.add_variant method and start to use the new order.contents.add. So, I'd create a new "Spree Upgrade" issue to adapt add_variant and I'd leave this issue open but in a different epic: [OFN API evolution]. What do you think? |
Update: The only new detail here is related to shipments: in spree 2 , when removing line items from a completed/finalised order, the shipments/stock_locations are updated in the order.contents.remove_variant. In case a finalised line_item is deleted from the order, I am not sure how is the stock being updated right now in OFN. So, my suggestion is to:
|
Yes, from memory, we don't need to do anything else for the Spree upgrade. So I'm happy with your solution. Let's focus on the Spree upgrade. |
ok, I have referenced this issue in openfoodfoundation/openfoodnetwork#2009. I'll leave this issue as it is. Note: both existing PRs openfoodfoundation/openfoodnetwork#2539 and openfoodfoundation/openfoodnetwork#2542 are still valid and will go forward. The work described in this issue is just not complete yet. I want to move this issue to Dev Ready but I cant decouple this issue state (Test Ready) from PR openfoodfoundation/openfoodnetwork#2542... |
I disconnected the PR @luisramos0 (you can do this via the PR, down the bottom near the comment field there is a connect/Disconnect zenhub section) and have moved it back to Dev Ready 😃 |
ah, now I see it. thanks! |
Should this be removed from Spree Upgrade epic @luisramos0 ? (Since you changed the title from [Spree Upgrade] to [OFN API Evolution]) |
Yes, done, thanks @sigmundpetersen |
This issue was related to a Spree upgrade which is finished. The code changed a lot since and I think that this issue is obsolete. Closing. |
Description
Spree 2 has changed order.add_variant and a few more things in Order and OrderPopulator. See the checkout customizations wiki page for context.
We propose to move away from extending Spree code order_decorator and order_populator_decorator and re-implement this logic in OFN.
So, there should be a new API endpoint for /cart that will take (to be confrmed): order_id, line_item_id and quantity. This will be implemented in Api::CartController. This controller should depend on new OFN service class CartService. This service will implement what's currently in order and order_populator and will depend, but not extend, Spree classes. Basically, what's in orderpopulator.populate and order.add_variant needs to be moved and adapted.
This change must be done on OFN master branch (so that we can validate and test easily) and then merged back to spree branch.
Additionally, and to support the upgrade to spree 2.1, we should move away from order.add_variant and use add_contents instead. This can be done later. If we make the code depend on order.add_variant we can then simply move from add_variant to add_contents.
Additionally, if not too difficult we would change the frontend to stop making bulk calls with groups of line items and make one call per line item. We can keep current API with bulk to make it easier for now.
Testing
It's a technical change, there should be no UX change in the add to cart process.
The text was updated successfully, but these errors were encountered: