-
Notifications
You must be signed in to change notification settings - Fork 11
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
Discuss about checkout workflow and eventual solutions #9
Comments
forgot to mention there's a proof-of-concept branch with an initial state machine: https://github.com/nebulab/nova/tree/state_machine |
Maybe a middle ground approach will be better. I mean the developer that is going to use nova as e-commerce framework should implement the state machine based on the checkout flow that his system needs. I think the state machine should be implemented at the orders level. What do you think @ageacox? |
@mvidaurre yes! I agree in general, that was also the first idea I thought. But then I asked myself: do we really need steps? The most basic use case might be something like:
Which can be achieved with a single function/command. In other words: are we sure we need steps to manage checkouts? Isn't it better to find a solution that gives the features (pay, store info, ...) while leaving a certain degree of freedom for devs? Sure we'll need to store some state that n orders, but I'd like to explore eventual alternatives to state machine. What do you think? Let's discuss! :-) |
After some pencil+paper, I've found a potential alternative. Considering that the general goals are:
I came out with this initial hint: A The function takes an This approach would offer more flexibility for eventual customizations. What do you think? |
here's a simple example about my idea: Take a
it
it exposes two
Now, suppose a dev wants to change something in the checkout process. He could write something like this:
then change the
so that now it will call different functions:
@mvidaurre what do you think? :-) |
@apeacox IMHO we should make and step back and really check what we want to build?
Based in our discussions I think our intention is to build an ecommerce framework and base in that framework build an ecommerce platform that will be inspired by spree. Am I right? Or do you have any other view? |
I think the approach that you are proposing is fine. And that could be our starting point. |
@mvidaurre yes, I want to build a minimal ecommerce platform (inspired by spree) built on a framework and easy to extend through packages/extensions. That said, I'd like to avoid the problems encountered with Spree in several occasions, and relying on a state machine for checkout is one of these. This is why I'm exploring alternative ways to implement the same feature. In general, I'm also trying to think forward when it comes to extensibility/customization other than familiarizing with Elixir and FP patterns. In the case of state machine, I have created a branch (https://github.com/nebulab/nova/tree/state_machine) some day ago and I've noted the following pain points:
The alternative solution I've presented, shows that it's still possible to mimic a state machine behavior, without depending on it. for example, what if we have two
the first one, after it finished, returns the next state, along with other meaningful data. IMHO this is a very simple and explicit approach to solve the problem. of course, the platform/framework will define one or more default modules to draw the desired checkout process. as a side note, I'd like to assure I'm not defending this proposal as the only possible one, I've just thrown the idea on the table to discuss about it and explore if it fits better. the state machine was my first go to solution, but I wasn't 100% convinced about it. however, I'm not arguing my approach is better, that's why I'd like to discuss it here with arguments/examples/use-cases :-) |
You should be striving for "small modules that do one thing well." A friend showed me this video about a developer programming a board game using Elixir. In it the speaker shows how to simplify your code by properly organizing your logic such that each module is responsible for one thing. Instead of saying "checkouts are where you can add payment information" you just create a Then your checkout flow looks pretty simple: |
thank you @kolorahl for the hints! :-) I mostly agree with your approach and I was impressed by the video you linked here (it was in my to watch list and finally I found some time to check it out). In this specific case, I had to handle some tradeoffs because I'd like to release something that works in the short term. The problem with too much separated modules relies in the effort needed to customize checkout without touching too much code. On the other hand, at least, I tried to separate modules by feature :P In commit 3fa1bc1 I've added initial billing support through commerce_billing package, just to see how if it works ;) what do you think? |
Ok, I see what you're doing there. You're relying on I'm not sure why you're defining |
@kolorahl I'm glad you appreciated my proposed solution :) it's still undone, but I think it's a decent starting point. just to clarify a bit, you can see a proof-of-concept demo in this gitst the point about The reason to use hope this cleared your doubts. however, if you know a better solution, feel free to suggest it here :) |
On the UI side, you might want to check out drupal commerce, they really managed to nail it for customising the checkout UI. |
Checkout is a tricky thing, so it would be better to discuss here eventual solutions. I'm still not sure we'd need a state_machine to manage this.
For our experience on Spree, having a rigid schema (such as a set of states managed by state machine) it's not that useful, especially when working with APIs.
One possibile solution might be to have stand-alone functions to run for each step, then it's up to developers to customize the order of steps in the workflow. After all, it's not a rule to follow a set of steps to do a checkout, right? :-)
As a reference, check this simple example of a checkout payment with Phoenix: https://github.com/joshnuss/phoenix-billing-demo
However, I'm open to suggestions, hints and similar
The text was updated successfully, but these errors were encountered: