-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Core] [WebBundle] Implemented Guest checkout #1816
[Core] [WebBundle] Implemented Guest checkout #1816
Conversation
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('email', 'email'/*, array('label' => 'sylius.form.checkout.')*/) |
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.
You should remove this comment...
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.
Fixed
Instead of again adding something to order, what about creating something like Additionally that feature should be optional, and probably not enabled by default ;) |
@@ -191,6 +192,10 @@ | |||
<argument>%sylius.model.cart.class%</argument> | |||
<tag name="form.type" alias="sylius_checkout_payment" /> | |||
</service> | |||
<service id="sylius.checkout_form.guest" class="%sylius.checkout_form.guest.class%"> |
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.
Please use same naming as in other forms: sylius.form.order.guest_checkout
.
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.
So other forms for checkout steps also has incorrect ID's names like:
- sylius.checkout_form.payment
- sylius.checkout_form.shipment
- sylius.checkout_form.shipping
am i right?
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.
Those are one of the oldest ones, I have in mind creating PR that fix this, but IMO new one should be named more correctly (note that suggested by my is just proposal).
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.
Fixed
ffee690
to
924bf07
Compare
@@ -20,6 +20,7 @@ | |||
|
|||
<parameter key="sylius.form.frontend.profile.type.class">Sylius\Bundle\WebBundle\Form\ProfileFormType</parameter> | |||
<parameter key="sylius.form.frontend.registration.type.class">Sylius\Bundle\CoreBundle\Form\Type\RegistrationFormType</parameter> | |||
<parameter key="sylius.listener.registration.class">Sylius\Bundle\WebBundle\EventListener\RegistrationListener</parameter> |
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.
Seems like you removed that file from commit.
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.
Accidentally during rebasing. Now should be good.
924bf07
to
2534b7b
Compare
@stloyd the reason why I was added email field into Order was that both types of customers(registered and guest) should have correct history of orders(in this particular case we keep information which email address was used to send Invoice). Keep this information in order entity we cover both cases at once. Even if Guest checkout will be disabled we should keep email history for registered customers. According to previous discussion in #90 may be it will be better idea to treat it like proposed @Richtermeister :
|
|
||
if ($guestForm->handleRequest($request)->isValid()) { | ||
$this->getManager()->persist($order); | ||
$this->getManager()->flush(); |
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.
Blank line before return
.
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.
done
Nice work @torinaki, I think it is the simplest (and best for now) approach for this. I also like the registration code duplication removal. 👍 One thing to consider, when I merge this, we need to be always aware that Order does not always contain a reference to user. This is important for promotions, shipping and pretty much everything else. It seems quite ready to me (at least for initial implemenation), so I'd love to gather some feedback. @kayue @stloyd @umpirsky @Arn0d @Sylius/core-team I know that @umpirsky and @kayue implemented something like this, right? For HB? |
{% if order.user %} | ||
<p>{{ order.user.fullName }} <br><a href="{{ path('sylius_backend_user_show', {'id': order.user.id}) }}">{{ order.user.email }}</a></p> | ||
{% else %} | ||
<p>{{ order.email }}</p> |
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.
How about this?
<a href="mailto:{{order.email}}">{{ order.billingAddress.firstName }} {{ order.billingAddress.lastName }}</a>
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.
I fix it a little bit different. I did not added mailto links, because I want make different look between user that have profile and link to it and user that do not have profile.
Please take a look I guess you will like it.
@pjedrzejewski @torinaki I like this too. I think we can use the name from the billing address. This can avoid some In our project we create user on the fly to avoid changing the core. This PR is better 👍 |
@kayue Its quite possible that the billing address is not your customer. It could be a wife using the husband's card, or an employee using the company card, etc. For these scenarios the billing address cannot reliably give you the customer details. Even the shipping address would be unreliable, as it could be a gift being sent to a relative, etc. |
@robholmes I tend to disagree with you. If customer info can be different from billing address, then we should ask for customer info in addressing page. (ie: a separated And in fact I think having a separated |
@robholmes I am working on a payment gateway and it has the following XML model, I think we can use it as reference. I like how they have a
|
In fact the current Sylius checkout flow is not perfect:
If customer choose to pay with PayPal, he shouldn't have to provide billing address to Sylius, because billing address will be returned from PayPal anyway. The current checkout flow is duplicated. So it is better to use Contact to replace Billing Address at the first step. It also solve @robholmes 's wife scenario.
|
Fixed fatal on checkout. Improved guest customer info in admin.
} | ||
|
||
/** | ||
* Render step. | ||
* | ||
* @param ProcessContextInterface $context | ||
* @param FormInterface $registrationForm | ||
* @param FormInterface $guestForm |
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.
$guestForm and $registrationForm should be aligned
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.
Done. I have adjusted my IDE settings, hope it will be last comments about code style :)
Do I need to wait green build on travis? I guess there is a problem with Behat execution time. |
@@ -50,6 +50,7 @@ | |||
<field name="currency" length="3" /> | |||
<field type="string" name="paymentState" column="payment_state" /> | |||
<field type="string" name="shippingState" column="shipping_state" /> | |||
<field type="string" name="email" column="email" nullable="true"/> |
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.
IMO this is acceptable to land in OrderBundle
instead of CoreBundle
, along with code changes.
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.
I think CoreBundle
is a better place. In OrderBundle
we don't even have address there.
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.
I would agree that e-mail field could go to the Order component & bundle, but only this field.
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.
Hmmm... in fact, we could even consider this field on address instead of order...
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.
No, I think it should stay on the order, that's what Spree does and it feels most natural. Simplifies searching by e-mail etc.
Fixed and added spec tests
@@ -46,6 +46,7 @@ public function __construct(TwigMailerInterface $mailer, array $parameters) | |||
*/ | |||
protected function sendEmail(array $context, $recipient) | |||
{ | |||
echo $this->parameters['template']; |
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 is for sure something that can't be in accepted.
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.
:D Sorry about that. Fixed
@torinaki Please merge dbalabka#2 as it finishes this PR so it can be merged into Sylius! =) |
Fix code after feedback, add ability to disable guest orders
@pjedrzejewski Can you have a look on this? IMO it's good for merge! |
[Core] [WebBundle] Implemented Guest checkout
Thank you @torinaki for this super-cool feature and Joseph + Arnaud for the review! :) |
…checkout [Core] [WebBundle] Implemented Guest checkout
…checkout [Core] [WebBundle] Implemented Guest checkout
…checkout [Core] [WebBundle] Implemented Guest checkout
I have created a possibility for Guest customers to checkout only using email. Order entity now always has information about customer's email(even if customer was registered). I have removed duplicated registration logic from Security step. Registration form still exists on Security step page as is, but registration request will be addressed to main registration controller. After successful registration customer will be redirected back to checkout.