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 state is not updated moving from '/cart' to '/checkout/address' #4079

Closed
ghost opened this issue Dec 8, 2013 · 8 comments
Closed

Order state is not updated moving from '/cart' to '/checkout/address' #4079

ghost opened this issue Dec 8, 2013 · 8 comments

Comments

@ghost
Copy link

ghost commented Dec 8, 2013

Version: 2.0.3
Behavior: When a user is signed in and clicks "Check Out" button on "/cart" page, the order's state remains "cart".
Repro Steps:

  1. sign in
  2. add any product to cart
  3. click "check out" button on "/cart" page
  4. reaches "/checkout/address"
  5. check the orders view in backend, and you'll see the state of the order remains "cart"
    Possible Cause:
    Although the "load_order" before_filter in CheckoutController changes the state to params[:state], it doesn't persist it.
if params[:state]
          redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
          @order.state = params[:state]
        end
@radar
Copy link
Contributor

radar commented Dec 9, 2013

Please try using the 2-0-stable branch and let us know if you are seeing the same issue. 2.0.3 is 4 releases behind the latest for that branch.

On Mon, Dec 9, 2013 at 9:51 AM, Jincheng Li notifications@github.com
wrote:

Version: 2.0.3
Behavior: When a user is signed in and clicks "Check Out" button on "/cart" page, the order's state remains "cart".
Repro Steps:

  1. sign in
  2. add any product to cart
  3. click "check out" button on "/cart" page
  4. reaches "/checkout/address"
  5. check the orders view in backend, and you'll see the state of the order remains "cart"
    Possible Cause:
    Although the "load_order" before_filter in CheckoutController changes the state to params[:state], it doesn't persist it.
if params[:state]
          redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
          @order.state = params[:state]
        end

Reply to this email directly or view it on GitHub:
#4079

@huoxito
Copy link
Member

huoxito commented Dec 9, 2013

I remember someone brought this on the spree-users group a couple weeks ago. I think we need to call order.next when the user clicks on that checkout button. Not sure if this was fixed.

@ghost
Copy link
Author

ghost commented Dec 9, 2013

tried with 2-0-stable, same behavior.
I agree with @huoxito that calling order.next should solve the problem. What's the reason for using " @order.next_transition.run_callbacks if @order.cart?" instead of " @order.next if @order.cart?" in OrdersController#update?

@radar
Copy link
Contributor

radar commented Dec 10, 2013

I wish I had an answer for that question other than "it seemed like a good idea at the time" 😉 I will see if the frontend component's tests complain about that change. If they don't, then it'd make sense to call next here rather than just the callbacks for the next transition.

@radar
Copy link
Contributor

radar commented Dec 10, 2013

It would seem this would be because an order cannot go from the cart state to the address state. Calling next here causes the orders_controller_transitions_spec.rb test file to fail. I will leave a comment in OrdersController now to alleviate confusion.

@radar
Copy link
Contributor

radar commented Dec 10, 2013

Better still, it seems that the fix for this is relatively easy. Just move the require_email to be later in the checkout, at whatever state is not "cart" or "address". I've got a patch that does just that in on my 2-0-stable, 2-1-stable and master branches now.

@ghost
Copy link
Author

ghost commented Dec 10, 2013

Awesome! Thanks for the prompt response @radar !

@radar radar closed this as completed in 177fecf Dec 11, 2013
radar added a commit that referenced this issue Dec 11, 2013
This means that an email field can now be provided on either the cart or address forms

More importantly, the 'state' field will now say 'address' when users reach that state, rather than 'cart'

Fixes #4079
radar added a commit that referenced this issue Dec 11, 2013
This means that an email field can now be provided on either the cart or address forms

More importantly, the 'state' field will now say 'address' when users reach that state, rather than 'cart'

Fixes #4079
radar added a commit that referenced this issue Jan 9, 2014
This means that an email field can now be provided on either the cart or address forms

More importantly, the 'state' field will now say 'address' when users reach that state, rather than 'cart'

Fixes #4079
@ghost
Copy link
Author

ghost commented Jan 12, 2014

There might be an issue with this fix depending on how you view the checkout logic. When a customer clicks checkout on the /cart page but stops on the sign in page, the order state is one step ahead and changed to delivery. This can be misleading when you look at all the orders and analyze the conversion funnel.

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