Skip to content
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

Order totals and promotion adjustments are not applied when created via API #2565

Closed
mathportillo opened this issue Feb 9, 2018 · 1 comment

Comments

@mathportillo
Copy link

To reproduce:

  • create new order via solidus_api
  • as a non-admin user
  • with line items

Result:

  • line_itens adjustments are not created
  • totals are not calculated

#2490 tries to solve this issue. But it ditches the use of OrderUpdateAttributes on Api::OrdersController. However, OrderUpdateAttributes is still used on Api::CheckoutsController on the update action.

The questions I raise are:

  • Should the current behavior of Api::OrderController really be considered wrong?

  • If Api::CheckoutsController relies on OrderUpdateAttributes, wouldn't it be susceptible to the same error as Api::OrdersController?

  • If Api::OrderController.update doesn't care about payment_attributes, should Api::OrderController.create care (for non admin users)?

  • If no, should OrderUpdateAttributes be removed from Api::OrderController, and the create action use order.contents.update_cart

  • If the above happens, should OrderUpdateAttributes get obsolete since only Api::CheckoutsController would rely on it, and instead it could rely on OrderUpdater.

  • If no, should OrderUpdateAttributes be altered to recalculate totals and apply cart promotions?

Sorry for so many questions, but there are many ways to fix the issue, and I could only help better with the guidance of the veterans.

@kennyadsl
Copy link
Member

All your doubts are justified. I think that simply, when we added the OrderUpdateAttributes, we didn't considered all these things.

I think that the real difference is that in the Api::CheckoutController it works because there are other things that recalculate the order later (probably the next call). Also, checkout and orders api controllers are thought to make difference things, otherwise one of them could potentially be useless.

I think it's safe to use the same code that we used in the Api::OrderController.update and in the frontend orders controller update action.

I'll talk about this with the core team today, thanks for reporting your doubts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants