-
-
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
Move checkout coupon code section into summary #2327
Conversation
That's all great! And all in for all the 3 next steps A current problem I'm always ending up solving with the coupon code not being a separate form is to detect when the enter key has been pressed, and submit just it .. as otherwise an Enter key would submit the payment form. $('#coupon_code').keypress (e) ->
if(e.which == 13)
Spree.onCouponCodeApply()
e.preventDefault() Separate controller and action is definitely the way to go! Ah, and one more - I'm also often needing to make a Thanks again |
30a47a0
to
261c9ca
Compare
261c9ca
to
ca6fab3
Compare
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.
This makes lot of sense. Could you please rebase with latest master
to see if this still works with Rails 5.1 and Rails 5.2 (See my comment about the insecure params usage).
ca6fab3
to
c1e37e8
Compare
It will be easier to add other context, like checking out with logged in user.
Both in checkout and orders controller. This feature was not tested at controller level. Adding specs will allow more confidence for future changes on this part.
There's no need to try to apply coupon code when its params is empty. Right now, submitting every form that have the coupon code field (cart and checkout payment), even with the field empty, it is uselessy calling the Spree::PromotionHandler::Coupon `new` and `apply`.
This method is used into Checkout and Order controllers, but they need some different behavior which now would be hard to add in a non-hacky way.
When coupon code handler has errors checkout controller needs an extra setup for current step views or it will not render correctly.
This commit moves the coupon code application section of checkout into the summary box, still visible in payment step only. It also wraps the coupon code input + button into a real form so it still works if, for some reason, JS is not working, falling back to submitting a simple order form for now.
c1e37e8
to
212287a
Compare
@tvdeyen changes requested done! |
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
This change is needed if we want to stop passing from checkout controller to apply coupon codes.
At the moment we have several issues with this behavior:
[:order][:coupon_code]
along with other params. We don't want this anymore since those actions are designed to work for orders and checkout controllers only. Seerender :edit
for example, it could not work in all scenarios. To fix this issue I duplicated this method in both orders and checkout controllers, I think in this case duplication is not bad, since real shared logic is handled byPromotionHandler::Coupon.new(@order).apply
and we'll need a different behavior in those controllers;TODO: in my plans next steps will be:
[:order][:coupon_code]
param in checkout controller. If this PR is merged we'll just have this behavior called as a fallback if for some reason JS is not working.