Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Inserting Customer ID into hyperlink as querystring in checkout_success

    Hello,
    I am using v1.5.1.
    A few weeks ago I did read somewhere how to do this and I can't find it now. I spent the whole day looking so I apologize for asking again since I am sure this has been covered.

    What I am trying to do is create a link on the checkout_success page using the define_checkout_success_page in the admin interface. I can successfully create the hyperlink but I can't get the value for $_SESSION['customer_id'] into my url as a variable to pass along to another page. This is what I have that is not working.

    <a href="http://mydomain.com/Default.aspx/?ID=$_SESSION['customer_id']">Link text</a>

    what you see is what I get. It successfully sends you to the new page but instead of ?ID=value it remains ?ID=$_SESSION['customer_id']

    This is what shows in the address bar after following the link:
    mydomain.com/Default.aspx/?ID=$_SESSION['customer_id']

    Any and all help appreciated.

    Good Night all,

    Mark

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    Quote Originally Posted by marksmanaz View Post
    What I am trying to do is create a link on the checkout_success page using the define_checkout_success_page in the admin interface. I can successfully create the hyperlink but I can't get the value for $_SESSION['customer_id'] into my url as a variable to pass along to another page. This is what I have that is not working.

    <a href="http://mydomain.com/Default.aspx/?ID=$_SESSION['customer_id']">Link text</a>

    what you see is what I get. It successfully sends you to the new page but instead of ?ID=value it remains ?ID=$_SESSION['customer_id']
    The problem is because you are "quoting" the entire string/URL, as such, "$_SESSION['customer_id']" is being taken literally.

    Try rewriting the URL so it reads:
    <a href="http://mydomain.com/Default.aspx/?ID=".$_SESSION['customer_id']>Link text</a>

    (note, I've removed the end quote and placed it after the '='). The 'dot' between the 'new' quote and the $_SESSION variable is PHP's method of concatenating two strings. Since the $_SESSION variable is now 'exposed' (not contained within quotes) the actual ID will be inserted after the '='.

    Cheers
    Rod

  3. #3
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    RodG,
    Thank you so much, I needed a fresh set of eyes. Unfortunately now that I changed the hyper link by moving the quotes in I only get this:

    mydomain.com/Default.aspx/?ID=

    I know I am in session because I can see that my test customer is logged in. Can I assume that the customer_id session variable is filled every time a customer logs in? Or only after creating an account? I will try another variable to see if I can pull any value from the session at all. Any suggestions would be great.

    Thank you,

    Mark

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    Quote Originally Posted by marksmanaz View Post
    Can I assume that the customer_id session variable is filled every time a customer logs in? Or only after creating an account?
    I'd assume it'll be set whenever the customer is logged in. you know what they say about assumptions though.

    Quote Originally Posted by marksmanaz View Post
    I will try another variable to see if I can pull any value from the session at all. Any suggestions would be great.
    Regardless of what you find, one suggestion I will make anyway, is rather than blindly assuming the $_SESSION['customer_id'] will be set and using it for the URL, I'd be inclined to perform a pre-check.

    Something like:

    if (isset($_SESSION['customer_id'])) {
    $URL = "<a href=\"http://mydomain.com/Default.aspx/?ID=\".$_SESSION['customer_id']>Link text</a>" ;
    echo "$URL" ;

    } else {

    echo "$_SESSION['customer_id'] not set" ;
    }

    (Note how I've needed to 'escape' the embedded quote characters in this example).

    Cheers
    Rod

  5. #5
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    Thanks again Rod,
    I am going to make another assumption here (lol) as I place this code in the define_checkout_success.php in the admin tools section it actually shows the code on the success page. That will be telling me that I can only use html in the define_checkout_success.php page. Where should I be placing this code to get the proper output of "Link Text" as a hyperlink on the page to the define_checkout_success.php page? Or do I need to "wrap" the code in some way so it renders from there properly?

    Thanks again

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    If you were getting the (incorrect) info added to your URL string, you were probably editing in the right place; but we need more context to advise correctly on how to make it work.

    Is your link code inside or outside of <?php ?> tags? Outside will be outputting straight HTML and you would use something like
    PHP Code:
    <a href="http://mydomain.com/Default.aspx/?ID=<?php echo $_SESSION['customer_id'];?>">Link text</a>
    If inside PHP, the link string will be echoed or added to a variable for output, and you would have something resembling
    PHP Code:
    $content .= '<a href="http://mydomain.com/Default.aspx/?ID=' $_SESSION['customer_id'] . '">Link text</a> '
    Posting several lines around the place you are editing will help us help you.

  7. #7
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    I am sorry it has been a few days since I left off on this I had other urgent matters to attend to and I am now just getting back to this issue.

    gjh42 I have attached a screen capture so you can see what I mean about the actual code that RodG suggested I used show on the checkout_success page. As you can see the code is visible to the user and does not render as intended. I am inserting the code in the define_checkout_success.php in the admin tools section.

    This is what I have inserted into the page using the define pages editor:

    <p><strong>Checkout Success Sample Text ...</strong></p><p>A few words about the approximate shipping time or your processing policy would be put here. </p>
    <p>This section of text is from the Define Pages Editor located under Tools in the Admin.</p>

    if (isset($_SESSION['customer_id'])) {
    $URL = "<a href="http://mydomain.com/Default.aspx/?ID=".$_SESSION['customer_id']>Link text</a>" ;
    echo "$URL" ;

    } else {

    echo "$_SESSION['customer_id'] not set" ;
    }

    Any help appreciated as I am new to php.

    Thanks,

    Mark


    Name:  LinkText.jpg
Views: 1463
Size:  52.6 KB

  8. #8
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    Quote Originally Posted by marksmanaz View Post
    if (isset($_SESSION['customer_id'])) {
    $URL = "<a href="http://mydomain.com/Default.aspx/?ID=".$_SESSION['customer_id']>Link text</a>" ;
    echo "$URL" ;

    } else {

    echo "$_SESSION['customer_id'] not set" ;
    }
    Before this code you'll need to add a line that reads

    <?php ; // turns PHP on //

    Then after the code you'll need to add

    ?> ; // Turn PHP off. (unless more php code follows)

    Cheers
    Rod

  9. #9
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    I want to take the time to thank Rod and gjh42 for all their help as I was able to get the customer ID to carry over in a query-string following their instructions. Thank you so much and have a wonderful day.

    Mark

  10. #10
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Inserting Customer ID into hyperlink as querystring in checkout_success

    Quote Originally Posted by marksmanaz View Post
    I want to take the time to thank Rod and gjh42 for all their help as I was able to get the customer ID to carry over in a query-string following their instructions. Thank you so much and have a wonderful day.
    Thanks. We appreciate knowing the problem has been solved. Your personal thanks is icing on the cake :)

    Cheers
    Rod

 

 

Similar Threads

  1. v150 Inserting a jpg into the footer
    By ocmusic in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 6 Jun 2013, 02:59 AM
  2. v139b Database inserting into upgrade
    By Philibel in forum Upgrading to 1.5.x
    Replies: 2
    Last Post: 23 Feb 2013, 10:37 PM
  3. Inserting a string into PHP
    By bhensarl in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 5 Nov 2010, 11:46 AM
  4. Inserting image into main page
    By Birdy Box in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 17 Nov 2009, 12:53 PM
  5. inserting into an existing site
    By kcable in forum General Questions
    Replies: 3
    Last Post: 15 Sep 2009, 04:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR