It would be cool to have a checkout redirect option directly on Drupal Commerce instead of having to use a specific module (ie : commerce_checkout_redirect).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GuGuss’s picture

I'm proposing that patch (worked with theo_) for that.

GuGuss’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1736850-checkout-redirect-1.patch, failed testing.

rszrama’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

Note that we can't have Cart depend on Checkout and Checkout depend on Cart. You'd never be able to uninstall either one. : )

theo_’s picture

It seem obvious not to have both module cart and checkout which depend on each one another ...

So should we implement this functionality in the cart module ?

rszrama’s picture

As written, yes it should be part of the Cart module. That said, I'm not sure the approach is sufficient and may be better off remaining a contributed module. (For example, it appears any Drupal login would be sending the customer to the checkout form, no?)

theo_’s picture

Only if the user have a cart, then yes it would be redirected to the checkout.

Maybe we should set up an additional session variable when an anonymous user try to checkout, then we will be able to redirect only users who wanted to checkout.

theo_’s picture

Version: 7.x-1.x-dev » 7.x-1.2
Component: Checkout » Cart
Status: Needs work » Needs review
FileSize
2.67 KB

Here is the new patch :
Checkout redirect is attached to the Cart module.
Only users who wanted to checkout while anonymous will be redirected to checkout, according to a session variable.

Status: Needs review » Needs work

The last submitted patch, 1736850-checkout-redirect-2.patch, failed testing.

rszrama’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Needs work » Needs review

Retesting on 7.x-1.x-dev.

theo_’s picture

#8: 1736850-checkout-redirect-2.patch queued for re-testing.

Haza’s picture

+++ b/modules/cart/commerce_cart.moduleundefined
@@ -228,6 +228,39 @@ function commerce_cart_form_alter(&$form, &$form_state, $form_id) {
+  $order_id = commerce_cart_order_id($GLOBALS['user']->uid);

In some case here, when the user log in, he got the right uid but the order (and the order also have the correct user_uid) but since we rely on a static variable in commerce_cart_order_id(), it can still have the order with uid = 0.

New patch attached.

Haza’s picture

Oops, just saw that we also miss to check if the session variable exist or not (might throw a notice).

Fix

Haza’s picture

We saw, on a project, that the drupal_goto() might be a little to brutal. (skipping some other form submit function that came after that), so, new patch but this time, using a $form_state['redirect'] to redirect the user.

jsacksick’s picture

I just found a bug in the #14 patch, you were able to checkout by going to checkout/order_id directly, I updated the logic and I implemented a hook_commerce_checkout_redirect(). in the commerce_cart module.

jsacksick’s picture

New patch that directly acts on the checkout module instead of the cart module.
This also adds a fieldset called "Checkout settings" where I added the checkout redirection setting.
Here is a screenshot : http://cl.ly/image/0V3X3J3t2O0G

bojanz’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

4 years later, it's safe to say this isn't happening. We did do it in 8.x-2.x, though.