This is the goal: Once user click on a link, product needs to be added to the basket, and order information page needs to appear, so user can fill it.

I've created a controller, and everything works, unless the user in anonymous. In that case, a "You are not authorized to access this page." error appears, and product is not added. However, (not sure if this is important), if the user visits a product first (just visit, without additional interaction), and then visit the link there is no that error. Also, if there are some items already in the added (with classic buttons), everything also works, for anonymous users as well.

I've used this to add the product: https://www.drupal.org/node/2866020

Shortly, it creates order item, and adds with cart manager.

and at the end, I've added

$cart_id = $cart->get('order_id')->getValue(); $cart_id_value = $cart_id[0]['value']; $response = new RedirectResponse('/checkout/' .$cart_id_value.'/order_information'); $response->send(); return;

Any help or guidance will be appreciated.


  • I don't know what the issue could be, but don't use hardcoded URLs: Use their route names instead, with parameters.
    – ssibal
    Commented Feb 4, 2019 at 14:19

1 Answer 1


I've solved this by replacing last 3 lines with

return $this->redirect('commerce_checkout.form', array('commerce_order' => $cart_id_value));

And as ssibal suggested, here I do not use hard-coded URL (thanks for that).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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