1

I want to have products that not require to stay logged and other that need it. So i think the best way is set in the admin "Allow Guest Checkout = Yes" and when the client goes to the checkout and there's products that require the login i send him/her to the checkout.

Or maybe it's better to use an observer.

I need to know what's the name to the interceptor (or the observer).

UPDATE

I think ask the client to login after add determinate products may be confused, so, i want to add it just in the last point, when you push on"Proceed to checkout" after the www.test.com\checkout\cart in www.test.com\checkout, where you see the direction to the shipment.

2
1

This is the event i'm looking for: controller_action_predispatch_checkout_index_index

from here

0

I'm not sure if I understand your question correctly but ...

It's not that interceptors have 'names'. I think your referring to the class name you want to hook into. This concept is called 'plugins' in Magento 2.

But I'm not even sure if that's the best solution for your question. Basically, what you want is that some products can only be ordered by logged in customers right? So I'm assuming your products have some kind of yes/no-attribute that determines this.

So there are various paths you could walk here:

  • Catch the event when a product is added to the cart (or the cart is updated), check if the products is 'one of those', and redirect from there. However, I'm not sure if Magento 2 is still so prone on catching events. I think plugins have preference over events. You could check the quote models for this one.
  • Intercept the (public) method that handles that 'adding of a product to the cart', you could check the cart controllers for this one.
  • If you really want to ask to login on checkout (and not earlier), you should hook into the controller of the checkout/index page, check the quote and redirect if needed.
  • Another way (requires more work) would be to determine if the 'add to cart'-button should be shown at all for those products if the customer is not logged in. From a UX point of view it's quote annoying if I want to complete my order and at that point I realise I need to make an account. It would be better to inform this up front. But that's just my 2 of cents. After all, I'm a developer, what do I know about UX? :-P

Perhaps you could update your question with what direction you wish to take so the community can help you better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.