Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2008
    Posts
    22
    Plugin Contributions
    0

    Default Prefill Text Attribute with parameter passed in URL

    Hello all, my first post. The FAQs and forums have kept me going pretty well, but now I'm stalled.

    I have a need to prefill a text attribute with a parameter passed in on the url of the product_info page.

    My customer sells photographs from their historical archives collection. With over 50,000 photographs, having a separate product for each photograph is unrealistic, so I have one Photograph product with an attribute to specify the photo number they want to purchase. The photographs can be searched and viewed from their web site, and I would like a user to be able to purchase a photo by linking directly to the product_info page at http://chessieshop.tracefork.com/ind...oducts_id=1860 with the Photo Number attribute prefilled for them with the photo number they were viewing.

    So I am looking for hints on what zen code do I need to change to allow my zen-cart to accept something like "http://chessieshop.tracefork.com/index.php?main_page=product_info&cPath=46&products_id=1860&PhotoNumber=12345.678 "

    and then prefill the Photo Number attribute with 12345.678

    Thanks,
    Lars

  2. #2
    Join Date
    Sep 2008
    Posts
    22
    Plugin Contributions
    0

    Default Re: Prefill Text Attribute with parameter passed in URL

    Never mind, I have a better solution. I created a simple "Add To Cart" form on the photo browser page that includes the attributes I have on my photo product. Now the user can specify the size photo they want to order, hit Add To Cart, and I pass the Photo Number in a hidden input directly to their shopping cart. Works very well, and appears completely seamless to the user.
    Lars

  3. #3
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    customer issue Re: Prefill Text Attribute with parameter passed in URL

    Hi,

    This is exactly what I've been trying to do but I don't know enough php to make it happen. Could someone fill in the missing steps for me please? Or point me to some online resource and I'll take it from there?

    So far I have been looking at a Javascript solution:
    http://www.willmaster.com/library/ja...javascript.php

    http://www.willmaster.com/blog/javas...-fill-form.php

    But "The JavaScript can assign values to type="text", type="hidden", type="password", type="submit", and textarea form fields. Selection and check fields aren't supported."

    1. I need drop down boxes and radio buttons to be controlled with this. Does your method allow it?

    2. Would it make it safer to transfer sensitive data (customer email addresses) by converting it to a cookie before sending it between pages: eg. http://www.willmaster.com/library/ja...of-content.php ?


    Thanks in advance guys,

    Regards,
    shaztesting

  4. #4
    Join Date
    Sep 2008
    Posts
    22
    Plugin Contributions
    0

    Default Re: Prefill Text Attribute with parameter passed in URL

    shaztesting,

    1.
    I believe my method will work for any attribute type, as I a simply duplicating the zen-cart Add To Cart button. I use it for a drop down and a text field.

    You can see an example of a page I create with my Add To Cart button on my Photo Search Page.

    View that web page's source and look for the "form name='COHS-1295'" section and see how I pass in the parameters to the drop down 'id[7]' and the text field 'id[txt_8]'.

    I came up with the names 'id[7]' and 'id[txt_8]' by looking at the source of my zen-cart product page to see what the attribute field names and id's are on the Add To Cart button. You'll have to do the same for your cart page, as I am certain your zen-cart created names and id's for your products' attributes that are different from mine. Then create a duplicate Add To Cart form on your web page that has all your product's attributes and values included in it.

    If you click my Add To Cart button you will go to my zen-cart store and see the product detail page with the Photo Size and Photo Number attributes prefilled.

    2.
    I leave the security of personal data to others who claim to know more about it than I do.

  5. #5
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: Prefill Text Attribute with parameter passed in URL

    Hi Lars,

    Thanks for the quick reply and all the help. After spending so long on the javascript solutions I am very excited by the way you have showed me. I will definately try it out over the next few days (or however long it takes me to get it right).

    3. Will this work from any page on the net (e.g Windows2k3 server and an aspx page sending information directly to the cart)? Or only from within one PHP page to another?

    4. Is it is also possible to send the user to the product page and show the prefilled info to allow them to add to cart? (I do understand why you set it up to be hidden and that is quite amazing)


    Thanks,
    Shaztesting

  6. #6
    Join Date
    Sep 2008
    Posts
    22
    Plugin Contributions
    0

    Default Re: Prefill Text Attribute with parameter passed in URL

    Shaztesting,
    Glad you might be able to make use of my solution.

    3.
    It is just a html form that passes parameters to zen-cart, so it will work from any web page from any browser. Your web server does not get involved with sending info to zen-cart, so it doesn't matter what web server you have creating your pages. The Add To Cart form is going straight from your users' browser to your zen-cart web server, which is specified in the "<form action=..." portion of the Add To Cart form. (For example, my web server cohs.org sends out the Add To Cart button, but when the user clicks that button their request is sent to my zen-cart at chessieshop.com. It appears seamless to the user, but the cohs.org server never communicates directly with chessieshop.com. They are two completely different web servers.)

    4.
    You can tell zen-cart what attributes to prefill from within the zen-cart admin attribute controller, but changing them on the fly each time you send a user to the Product Detail page from outside zen-cart will require reprogramming the zen-cart php scripts that produce the product detail pages. I'm not very knowledgeable about php or zen-cart's php files, so can't really tell you where to go for that.

 

 

Similar Threads

  1. v150 Pre Select Attributes With Parameter in URL
    By ShopVille in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 3 Feb 2015, 10:31 PM
  2. v151 Option Value URL parameter?
    By philip937 in forum General Questions
    Replies: 13
    Last Post: 14 Dec 2014, 05:58 AM
  3. How to suppress URL &sort= Parameter?
    By rarpsl in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 15 Jan 2012, 11:11 PM
  4. Parameter $parameters not passed to zenCssButton
    By swguy in forum Bug Reports
    Replies: 0
    Last Post: 17 Jul 2007, 02:53 PM
  5. URL Parameter Passing
    By digger149 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 29 Jun 2007, 12:53 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