16 replies [Last post]
Max_Headroom's picture
Joined: 09/01/2008
Juice: 47
Was this information Helpful?

Hi all
I'm having problems in getting cart link to redirect. This is one of my links:
It adds the product to the cart, but there's no redirect to checkout (also tried destination=cart to redirect to cart)
I don't see any other people here complaining about it, so I guess the problem could be on my side or my Drupal installation.
Any ideas?

torgosPizza's picture
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4107
Re: Cart link redirect

I can't reproduce this. Are you on D5 or D6? Do you have any restrictions set at admin/store/settings/cart_links?

sam1am's picture
Joined: 12/13/2007
Juice: 57
Re: Re: Cart link redirect

I am having the same problem. Everything ends up redirecting to the front page no matter what I put in my links. I'm using


Using Drupal 5 and ubercart latest.

sam1am's picture
Joined: 12/13/2007
Juice: 57
Re: Re: Re: Cart link redirect

Okay it seems like the reason the redirect is not working is because the link is coming from a form. This is the code I'm using:

<form method="LINK" action="/cart/add/p12_q1-m0?destination=cart" class="cartButton">
     <input type="submit" value="Add to cart">

I'm looking for a workaround. All I need is an html button as a link.

libeco's picture
Joined: 06/09/2009
Juice: 10
Re: Re: Re: Re: Cart link redirect

Did anybody find a solution for this problem yet? I'm having the same problem with a non working redirect from a form.

I use this: $form_state['redirect'] = '/cart/add/e-p' . $node->nid . '_q1?destination=cart';

Which adds the product to the cart, but redirects to the front page.

pcaritas's picture
Joined: 09/20/2011
Juice: 3
Re: Re: Re: Re: Re: Cart link redirect

You need to separate out the query string portion of the redirect into a separate element in an array like so:

$form['#redirect'] = array('cart/add/e-p2104_q1','destination=cart/checkout');

nithiya's picture
Joined: 07/03/2009
Juice: 2
Add products to cart page when click size button


I am new to ubercart. I need to add product in cart page and i need more than one add to cart buttons.

I have four sizes of product with different prices. when i am clicking the size
button product will be added to cart page.

I used this code:

I don't know what i have to give instead of this "p12_q1-m0" and what it means?

Please explain me as soon as possible.

Thanks in advance

kash99's picture
Joined: 07/27/2009
Juice: 2
Please help

Does it have to do anything with replacing 'Update cart' and 'Checkout' buttons with images?

cfaadev's picture
Joined: 05/19/2009
Juice: 6
I am having the same problem...

I was using the following link on my site perhaps 2 weeks ago and it worked then:


It worked beautifully by adding the Bronze One (1) Year Membership to the cart and redirecting the user straight to the checkout page. To see the original page, go to https://thecfaa.com/node/164.

We have switched to four memberships consisting of one (1) and three (3) year for both Personal and Business. Now I am in the process of switching completely away from the cart by giving users two pages to choose their membership and sign up:

Page 1: Membership Application (https://thecfaa.com/node/380)--> the potential member clicks the "I Agree" button, and is redirected to the next page

Page 2: Membership Options (https://thecfaa.com/node/378) --> the potential member clicks their desired membership type, and the cart is suppose to add that membership "product" to their cart and redirect them straight to the checkout page (bypassing the cart).
For example, the code for the Personal One (1) Year is

The products are added successfully to the cart, however, the user is redirected to the home page. I have tried this both as an anonymous user, and as a logged in user. To check the checkout page, go to https://thecfaa.com/cart/checkout

If someone could PLEASE give me some direction in this, I would be greatly appreciated! In fact, it's for my job, so I'm sure my wife would be glad you helped me also, lol.

torgosPizza's picture
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4107
Re: I am having the same problem...

I think the issue is the slash. You might try URL-encoding it. Try: cart%2Fcheckout

Also, just FYI, how are your Cart Links being created? You should use the l() function. The fourth parameter in the l() function is the query (anything after a "?" sign). So yours would be..

print l('Buy Now', 'cart/add/p128_q1-ipersonal_one_year', NULL, 'destination=cart/checkout');

For more check out the API page: http://api.drupal.org/api/function/l/5

You can also have other parts of the cart link created automatically by using info from the node, such as $node->nid (for the one they are buying). Hope this helps.

cfaadev's picture
Joined: 05/19/2009
Juice: 6
Re: Re: I am having the same problem...

Thanks for the help torgos. I apologize for not seeing your reply sooner.

I have been using UC Add to Cart Tweaks for a few months, and now I'm having a problem again. 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...

torgosPizza's picture
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4107
Re: Re: Re: I am having the same problem...

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.

alexis@drupal.org's picture
Joined: 02/05/2009
Juice: 2
Using l() for Drupal 6

Thanks for the tip, in Drupal 6 l() changes slightly so this worked for me and I got the redirect correctly:

l('Buy now', 'cart/add/p128_q1', array('query' => 'destination=cart/checkout'))


marcus45's picture
Joined: 11/03/2009
Juice: 40
Re: Using l() for Drupal 6

I was having the same redirect problem when generating the link from within a form. What fixed it for me was changing the 'action' attribute like so:
$form['#action'] = url('cart');

Dynamo Solutions

Ruud's picture
Joined: 05/23/2010
Juice: 3
Re: Re: Using l() for Drupal 6

You can also set the form method to GET and add a hidden field with the name 'destination'.

It will look something like this:

<form action="cart/add/e-p3_q1" methode="get">
  <input name="destination" type="hidden" value="cart/checkout" />
  <input type="submit" value="Order" />


yashek's picture
Joined: 12/27/2010
Juice: 4
multiple attributes

I have two attributes. How to build the url in this case?
cart/add/p4_q1_a1o1 ...and the second one?

Edit: Solved
and it add it separated like i want.... Smiling

riya's picture
Joined: 01/10/2011
Juice: 12
node_checkout not redirecting

This the only thread I could find close to the issue I've just now raised :

If it's the same issue I'd be grateful if somebody could help me...