- 🇺🇸United States mikemccaffrey
In case anyone else stumbles here looking to do this, I believe this code will work perfectly well until the feature is added to core.
/** * Implements hook_form_BASE_FORM_ID_alter(). */ function MODULENAME_form_commerce_order_item_add_to_cart_form_alter(&$form, FormStateInterface $form_state, $form_id) { // Redirect the user to the shopping cart on submit. $form_state->setRedirect('commerce_cart.page'); }
- 🇮🇱Israel jsacksick
So... There's this issue ✨ Allow order types to have no carts Needs work which is about redirecting to checkout directly... It'd be great if from within the same patch we could support both usecases, but I'm afraid the other patch is focused on the checkout usecase...
Perhaps the order type setting could be the page to redirect to? But it isn't as easy as exposing the path to redirect to because some routes (like the checkout route) require extra parameters (i.e. the order).
- 🇮🇱Israel jsacksick
But maybe as part of this issue, the cart module itself could do this...