solidusio / solidusio/solidus_frontend
Checkout redirects to address step when promotions make the order free
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 3
- Forks
- 7
- Avg merge
- 1h 55m
- Merged PRs (30d)
- 6
Description
We are trying to assign to a single user a promotion that allow to have a free order (order + shipping) but from the delivery step, we are redirected to the address step.
Note: The Store Tax rate is equal to 0 by default.
Solidus Version:
All solidus versions
To Reproduce
-
Create a promotion with these two rules to get a free order (Order with Flat Rate 100% + Shipment free)

-
Set a tax rate to 0

-
Make sure the pre-selected shipping method doesn't cost 0

- Proceed with a checkout
Current behavior
From the delivery step, you will be redirected to the step address because Solidus tries to render the payment step, which shouldn't be enabled.
Expected behavior
Skip the payment step and go to the confirm step.
Additional context
If you try to set the first shipping method cost to 0, you will be able to finalize the order. This is because the rendered order's default total will be equal to 0, and therefore the payment step will be correctly excluded.
The problem is also related to not having a tax rate.
In this case, we will certainly not have a payment step.
So when Solidus render the delivery step, we have a shipment promotion that will be applied immediately after the delivery:
https://github.com/solidusio/solidus/blob/cff5fc0e67592ee87d85e4ae1dc8710c65bcbd18/core/lib/spree/core/state_machines/order.rb#L105
https://github.com/solidusio/solidus/blob/cff5fc0e67592ee87d85e4ae1dc8710c65bcbd18/core/app/models/spree/order.rb#L504-L507
The first shipping method pre-assigned (with an amount > 0), initialize the checkout_steps with the payment state because the order has a total > 0:
https://github.com/solidusio/solidus/blob/cff5fc0e67592ee87d85e4ae1dc8710c65bcbd18/core/app/models/spree/order.rb#L49
https://github.com/solidusio/solidus/blob/cff5fc0e67592ee87d85e4ae1dc8710c65bcbd18/core/app/models/spree/order.rb#L227-L230
So, the step will be considered during the @order.next, but it will be invalidated by:
https://github.com/solidusio/solidus/blob/cff5fc0e67592ee87d85e4ae1dc8710c65bcbd18/frontend/app/controllers/spree/checkout_controller.rb#L12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/lib/spree/core/state_machines/order.rb, core/app/models/spree/order.rb, and frontend/app/controllers/spree/checkout_controller.rb, following the linked checkout flow around @order.next and checkout-step initialization. Reproduce the promotion, zero-tax, nonzero-shipping case; done means checkout skips payment and reaches confirmation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100