I had been using UC Add to Cart Tweaks for a few months, and now I'm having a problem. We are adding a new product to our site, and therefore I have to redo our checkout process. I have been close to perfecting it, but no such luck. I have built a webform and I want the redirect to send the user to a cart link redirect url upon submission based on the option they choose in "Membership Options. I have the redirect adding the product correctly, but it still sends me to the frontpage. I will post the webform temporarily for anyone to look at and try to fix this...I have seen others who seem to have a similar issue.

Go to this link to see what I mean: http://www.thecfaa.com/node/20

The Membership Options are as follows:
https://www.thecfaa.com/cart/add/e-p130_q3?destination=cart%2Fcheckout|Personal - 3 years: $27
https://www.thecfaa.com/cart/add/e-p128_q3?destination=cart%2Fcheckout|Personal - 1 year: $10
https://www.thecfaa.com/cart/add/e-p377_q3?destination=cart%2Fcheckout|Business - 3 years: $65
https://www.thecfaa.com/cart/add/e-p131_q3?destination=cart%2Fcheckout|Business - 1 year: $25

As I said, the links work, i.e. the form is submitted correctly and the product(s) are added, however the redirect goes to the frontpage everytime. I'm REALLY frustrated...

Thanks to any and all who can help...

Comments

rszrama’s picture

I don't understand why you have the pipe and text appended to the redirect URL. It should just be destination=cart/checkout.

thill_’s picture

I am not sure why that is there either.

But even

https://www.thecfaa.com/cart/add/p131_q1?destination=cart/checkout

is going straight to the home page like it is invalid. But node/131 is a product and such.

Have you tried unistall/reinstall the cart links module?

tr’s picture

Turn off Secure Pages then see if you're still having the problem. You might have to add cart/add/* to the list of secured pages.

Check your cart link restrictions settings at admin/store/settings/cart_links . You must either list ALL allowed cart links, or leave this blank.

Anonymous’s picture

I originally posted a request for help on ubercart.org back in May 2009 (http://www.ubercart.org/forum/support/9634/cart_link_redriect)

It was suggested to use the link with "cart%2Fcheckout" since the slash wasn't working. I am still having problems, so there must be something else going wrong.

torgosPizza suggested that I try the following

Well if it's a form, you can use $form['#redirect'] to force what page it will end up at.

To be honest I would probably, instead of using a webform that redirects to a Cart link, use a module to create a form which includes all the elements you need, and upon submission, uses uc_cart_add_item($nid) to loop through the options and add them to the cart... if that's a doable solution for you.

I am not sure how to put the correct "$form['#redirect']" values so I am going to try uninstalling cart links and then reinstalling them first. If that doesn't work, then I will try turning off secure pages. If secure pages is the problem, then I will add "cart/add/*" to secure pages and hopefully that will work. If anyone could explain in more detail how to use "$form['#redirect']" for a form created with the Webform module in the meantime, that would be great.

Thank you all for your input. I will post results here and on the ubercart forum.

Anonymous’s picture

Well, nothing worked. I uninstalled Cart Links and then reinstalled it. I already had Secure Pages disabled, but I tried enabling it and adding "cart, cart/*, cart/add/*" and I still get the redirect to the homepage.

I am still learning, but would it be possible to...

    1. Use a $form[#redirect] in the "Confirmation message or redirect URL" section of the webform (i.e. go to a confirmation page)
    2. Add something like "
$node->webform['confirmation'] = $form_values['submitted_tree']['membership_options']

to the "Additional Processing" section under "Webform advanced settings"

From my understanding, wouldn't this work to redirect to the appropriate page and add the product to the cart?

rszrama’s picture

Category: bug » support
Status: Active » Closed (won't fix)

I still don't understand why you're appending information after the path with the pipe. Regardless, the behavior you're experiencing doesn't appear to have anything to do with the cart links module, especially since the redirect there is a feature of Drupal's own function drupal_goto(). It very well could be a contributed module interfering with the behavior, but assisting on those sorts of support requests isn't something we do here in the issue tracker. For further support, please refer to the support forums on Ubercart.org. It might be someone doing support there has resolved a similar issue in the past.

lpeddie’s picture

rszrama, I realize this question was outside the scope of the issue tracker, but I'm wondering if cfaadev ever figured out the problem.

I'm getting the same error, no matter how I set the cart links expression (and I'm not using the pipe options), and am hoping to find a solution.
cfaadev -- if you found a solution (somewhere else) could you post it?

bob.hinrichs’s picture

The '?destination=cart/checkout' gets escaped. Your value has been changed to cart/add/p30_q1_m0%3Fdestination%3Dcart/checkout. This is of course the same as no destination value. The best solution would be to change cart links module to add another parameter so one could put the value into the string (.e.g. '_dcart/checkout'). Or maybe just an t/f/ option to set destination to the checkout page, since this would probably cover 99% of the use cases. Plus there are complications with putting a path in this value since slashes will cause it to be interpreted as a new argument.

I added this to line 116 of the module and it worked with URL cart/add/p321_q1_m0-c1:

      case 'c':
        // go directly to checkout page
        $redirect = intval(drupal_substr($action, 1)) == 1 ? TRUE : FALSE;
        if ($redirect){
              $_REQUEST['destination'] = 'cart/checkout';
        }
        break;

I would have submitted this as a patch but my software is not working today.

Here is another solution if we are not going to add this feature to the module. In your own enabled module, add this simple hook. (This is particular to our case where there is only one product and it always behaves this way...yours may differ).

function my_module_add_to_cart($nid, $qty, $data) {
  if ($nid==MEMBERSHIP_FEE_NID){
    $_REQUEST['destination'] = 'cart/checkout';
  }
}
Anonymous’s picture

I'm actually getting this error and NONE of the other parameters seem to work. I can't empty the cart or add new items at all... and the redirect always goes to the front page.

PatchRanger’s picture

Thanx bob.hinrichs, your recipe is working for me (I'm talking about custom module you offered in #8).
I insist to commit those few lines to freshest DEV version. This completely eliminates the problem in subj.