close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Specify a return url based on items in cart

Thread began 5/18/2010 3:23 am by JohnPicton | Last modified 5/19/2010 8:18 am by Jason Byrnes | 2519 views | 9 replies |

JohnPicton

Specify a return url based on items in cart

I would like to specify a return url to go to if there is a specific item in the cart. For example, the standard return url would be 'complete.php', but if there is an item of ID 1 for example in the cart I would like the return url to be complete2.php. I'm using PayPal.

Is this possible?

Sign in to reply to this post

CraigRBeta Tester

i have never tried it, but it should be possible.

On confirm.php you have a hidden field called return which is passed to paypal.

set this value to a session variable, which will have the return page url

by default, this session variable could be set to the standard return page.
if the specific item is added to the cart, change the session variable to the alternate page url,

Sign in to reply to this post

JohnPicton

Sounds like that should work! I'll give it a go.

Thank you!

Sign in to reply to this post

CraigRBeta Tester

good luck with that.

i just thought, you would also need to check if the 'special' item is removed from the cart

Sign in to reply to this post

JohnPicton

OK, I've created a session value in the way you've suggested and called it 'returnurl'. I've give it a value of the page I want to be the default redirect page. I've set the trigger as 'If Session Variable Is Not Defined'.

I've added this to the hidden field like this:

<input name="return" type="hidden" id="return" value="<?php echo $_SESSION['returnurl']; ?>" />

Can you advise how I would go about changing the value of the variable if a specific item is added to the cart?

Thanks again.

Sign in to reply to this post

Jason ByrnesWebAssist

Use the following code to check for Item ID 1 in the cart and change the value of the session:

php:
<?php

if($<Your Cart Name>->InCart("1") == true) {
  
$_SESSION['returnurl'] = "complete2.php";
}
?>




change <Your Cart Name> to the name of your eCart object.

Sign in to reply to this post

CraigRBeta Tester

Ok.

Firstly, test what you have done so far, to show that the session variable is being set and that the return works properly.

If this is OK, then step 2 needs a little bit of thought. (I haven't used ecart for a few months - if I don't get this right, perhaps someone from Webassist can step in)

From what i recall, there is a block of code on the cart page like this...

while (!$YOURCARTNAME->EOF()) were YOURCARTNAME is whatever you called your cart instance.

I think this is where the code loops through the cart array and sends it to the page

I think the best thing, is to do some 'if' statements within this loop, to check if the product id you are looking for is in the cart.

if it is, set a variable to true or something like that.

outside of this loop, test for true, and then set the session variable accordingly.

without looking at it in detail, i am guessing a bit, so i hope i don't led you astray.

Hopefully on of the WA guys can come in here too and advise.

Hope this helps


** What do you know, Jason got in there before me with what looks like an easier solution **

Thanks Jason

:-)

Sign in to reply to this post

JohnPicton

Thank you very much, both of you, for your really quick replies. It's much appreciated! I'll try it out and see where I get.

Sign in to reply to this post

JohnPicton

That's done it guys - thanks ever so much!

Sign in to reply to this post

Jason ByrnesWebAssist

Great, glad to hear it is working.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...