Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2013
    Location
    Portishead, North Somerset, United Kingdom
    Posts
    34
    Plugin Contributions
    0

    Default Modifying Products URL Link - Adding Client Variables Dynamically.

    Hi Guys,

    I'm modifying the Product Pages 'Product URL' input so that I can pass a user onto another website with some client variables. I have no need for it's normal use as is, so it makes sense I use it for something useful to me.

    I have this string that doesn't quite work. I'm using www.example.com for link example.

    Code:
    $products_url = $product_info->fields['products_url'].'&userid='.$_SESSION['customer_id'];
    This returns:
    http://www.example.com%26userid%3D1

    So the & = are being encoded incorrectly.

    I'm trying to achieve a link like this:
    www.example.com&userid=1 - My Customer ID being '1'

    Does anybody know of the correct way to encode this? Possibly with an example piece of code?

    Thanks

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Modifying Products URL Link - Adding Client Variables Dynamically.

    Do it in the template instead, in the zen_href_link function, adding your special extra string as the 2nd param. zen_href_link(base URL, params to add)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Oct 2013
    Location
    Portishead, North Somerset, United Kingdom
    Posts
    34
    Plugin Contributions
    0

    Default Re: Modifying Products URL Link - Adding Client Variables Dynamically.

    Thanks Dr Byte, That works perfectly. Just incase anyone wants to create something similar, the final code is as below for the tpl_product_info_display.php in the templates folder.

    This is the Product URL adding the Client ID (or whatever you require) to pass a user to a different website and keep track of them. It will only show when the user is logged in.

    Code:
    <!--bof Product URL  Hacked to only show when Logged in added '&& isset($_SESSION['customer_id'])' -->
    <?php
      if (zen_not_null($products_url) && isset($_SESSION['customer_id'])) {
        if ($flag_show_product_info_url == 1) {
    ?>
        <p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_url).'&userid='.$_SESSION['customer_id'], 'NONSSL', true, false)); ?></p>
    <?php
        } // $flag_show_product_info_url
      }
    ?>
    <!--eof Product URL -->
    :-)

 

 

Similar Threads

  1. v151 Manufacturers link adding host url?
    By gv321 in forum General Questions
    Replies: 7
    Last Post: 12 Feb 2013, 02:16 AM
  2. client says cart is auto matically adding attributes to their products
    By jill8026 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 28 Nov 2012, 02:08 AM
  3. Do I use seo URL or normal URL when adding an internal link?
    By gaffettape in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 24 Oct 2009, 01:22 PM
  4. Dynamically adding products to the catalog
    By flaminglogos in forum General Questions
    Replies: 0
    Last Post: 23 Aug 2008, 09:04 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