What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Prestashop: How I can add a variable (ex: $product_reference) as a prepopulated field in my form?

    Asked by ariom on June 11, 2015 at 08:01 AM

    Goodmorning all, 

    Is there a way to add the value of a variable (ex: $reference, $id_product, $produc_name or any other) as a precompiled field in my form depending on the product page i am coming from?

    I'm tryng to implement and embedd this form on a Prestashop 1.6.0.14, i can get all the variables i need but i don't know hou to make them to be filled in automactly on the right field.

    Can you pls give me a suggestion how to achieve this?

    Thanks in advance and best regards to you all.

    Mario

    Prestashop field variables php preference
  • Profile Image

    Answered by Carina on June 11, 2015 at 12:07 PM

    I'm not very familiar with Prestashop but I think pre-populate app can help:

    http://prepopulate.jotform.io/ 

    In this case it is the same form but the form's link will be different, according to the product:

    https://shots.jotform.com/carina/HTML/prepopulate.html 

    Let us know if this is a solution for you.

  • Profile Image

    Answered by ariom on June 12, 2015 at 01:24 AM

    Thanks for your replay.

    i looked to what you suggested, but unfortunatly it is not the solution i'm looking for.

    i have to call a variable value {$product->reference|escape:'html':'UTF-8'} depending on the product page where i click the button to go to the form, and the right form field should be dinamically precompiled with that value.

    you can see here what i mean:

    http://www.navyonepal.com/navyonepal/it/lista-dei-viaggi-in-bhutan/22-viaggio-culturale-nel-regno-del-bhutan-classico.html

    there is a button  "RICHIEDI IL PROGRAMMA DETTAGLIATO PER QUESTO VIAGGIO" calling a cms page with the form iFrame

    Any help is welcome....

    Thanks in advance

    Mario

  • Profile Image
    JotForm Support

    Answered by ashwin_d on June 12, 2015 at 06:40 AM

    Hello Mario,

    I did check the web page URL which you have shared but I am unable to find any button with text "RICHIEDI IL PROGRAMMA DETTAGLIATO PER QUESTO VIAGGIO".

    Can you please guide us where to find this button to be able to understand your requirement? You may also like to share a screenshot as well and we will take a look. The following guide should help you upload image in forum post:  http://www.jotform.com/answers/277033 

    I do have one another question as well. Do you mean to say that the PHP code "{$product->reference|escape:'html':'UTF-8'} " return the value which you need to prepopullate in your form field?

    We will wait for your response.

    Thank you!

  • Profile Image

    Answered by ariom on June 12, 2015 at 08:42 AM

    Really thanks for your replay,

    Here atached in screenshoot-1 you can see the button, just before the social icons, that call the cms page with the form Iframe from the product page, example from http://www.navyonepal.com/navyonepal/it/lista-dei-viaggi-in-bhutan/22-viaggio-culturale-nel-regno-del-bhutan-classico.html.

    In the second is the form Iframe with the field that should be prepolutated by the php variable"{$product->reference|escape:'html':'UTF-8'} " that should return the value that i need to pre-populate the field, depending on the product page i am, right as you say.

    I have no  way to insert the form but Iframe, cause any other is giving a lot of js conflicts...and i'm not a coder so it'svery difficult for me....

    Thanks for your time an your valuable help!

    Mario

  • Profile Image

    Answered by ariom on June 12, 2015 at 08:49 AM

    oops! i forgot screenshoot-2....:

    thank for helping

    Mario

  • Profile Image

    Answered by Carina on June 12, 2015 at 10:08 AM

    I will investigate further and will let you know as soon as I have more details.

    Let us know if we can assist you further.   

  • Profile Image

    Answered by ariom on June 12, 2015 at 12:20 PM

    Thank you so much for your time,

    at the moment i put the Iframe code on the product page so the button will just toogle the visibility of the form. this will make much more easy to get the current php variable{$product->reference} value because it is on-scope.

    Then i think the html for the input field should be as follow:

    <div id="cid_28" class="form-input jf-required">
    <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_28" name="q28_reference" size="20" value="{$product->reference|escape:'html':'UTF-8'}" />
     </div>
     </li>

    but i can't modify the form cause it is an iframe, and i'm not a coder so become very difficult for me to implement it inside prestashop also cause there are a lot of js conflicts, () already try to call jQuery.noConflict function but it is working only for some, not for all...)

    Any more help will be much appreciate...

    Thank you all,

    Mario

  • Profile Image

    Answered by Carina on June 12, 2015 at 01:46 PM

    Hello Mario

    If that is the case you can edit the form's source code and add it to a page and then add that page as an iFrame.

    You can see here the example:

    form source code page:

    https://shots.jotform.com/carina/HTML/Title%20Me.html 

    page embed as iFrame:

    https://shots.jotform.com/carina/HTML/iframe56.html 

    You can also see our guide on PHP forms:

    https://www.jotform.com/help/237-PHP-Forms-Explained 

    Let us know if that worked.

     

  • Profile Image

    Answered by ariom on June 13, 2015 at 06:33 AM

    Hello,

    thanks for your effort and suggestion!

    I will take the time to check later in afternoon and i'll let you know....

    hope it will work in some ways

    Thanks a lot ... wish you a nice weekend!

    regards

    Mario

  • Profile Image
    JotForm Support

    Answered by Welvin on June 13, 2015 at 05:20 PM

    Hi Mario,

    Can you also check this widget: http://widgets.jotform.com/widget/get_referrer ? If you are trying to get the page reference, this widget should do it.

    Thanks

  • Profile Image

    Answered by ariom on June 14, 2015 at 01:20 AM

    Thanks for your suggestion.

    I tried it, but unfortunatly it is not working for me, it is working if i try it with example widget form preview from the jotform panel, then i insert widget in my form, go to my site, open iframe form and send it, no referrer at all in the mail received...

    Any other suggestion is welcome...

    Thank you all.

    Mario

     

  • Profile Image
    JotForm Support

    Answered by Welvin on June 14, 2015 at 09:52 AM

    Hi Mario,

    Actually, your method of appending the PHP Snippet in the iFrame embed codes should work. You have the following:

    http://form.jotformeu.com/form/51612259464355?reference=<?php echo $product->reference ?> 

    However, you saved the page as an .HTML. PHP echo function can't work inside an HTML page. You should save the page as .PHP. 

    http://stackoverflow.com/questions/1100354/how-can-i-echo-html-in-php?rq=1

    Please get back to us if you need further assistance.

    Thanks

  • Profile Image

    Answered by ariom on June 14, 2015 at 12:00 PM

    Hi Welvin, thank you for helping.

    ... prestashop uses smarty as template engine so, looking at the page source, you see the page as .html, but the real page where i insert the iFrame embed codes with the php snippets it is a smarty template (.tpl) ... because of that it is maybe not working.

    Maybe I should then make a .php page on my root directory and call that .php page as iFrame in the .tpl, but in that case i'm going to have a lot of trouble with .js conflicts, i tried before with no result so i preferred just embed full form files as iFrame.

    I know i'm very close to solution, but i'm sorry, i've so little knowledge in coding, very basic, and i see this is going so far...

    I'm really gratefull for your help and support, will try again and see if i can get to the point.

    Best regards

    Mario

     

     

  • Profile Image
    JotForm Support

    Answered by Welvin on June 14, 2015 at 01:44 PM

    Hi Mario,

    I searched for a possible solution about this. What I've found is that you shouldn't use PHP echo. You should just do it like this:

    http://form.jotformeu.com/form/51612259464355?reference={$product->reference}

    Or this:

    http://form.jotformeu.com/form/51612259464355?reference={$product.reference}

    And then make sure that the above snippets are present in your .TPL file. Please try it and let us know if that works. If not, I would suggest contacting Prestashop Support and ask them if what's the best way to append the info in an external form like Jotform.

    Thanks

  • Profile Image

    Answered by ariom on June 14, 2015 at 04:49 PM

    WOW... IT'S WORKING...

    http://form.jotformeu.com/form/51612259464355?reference={$product->reference}

    was the solution...perfect as i need... so easy and simple that i could not see, i look far and i have it under my eyes!

    i have to thank you all for the patience to assist me ... you are really great!!!

    Mario

     

  • Profile Image

    Answered by ariom on July 18, 2015 at 01:12 PM

    I'm back again asking if somebody can help on the same question ... cause i see an issue

    I try to explain:

    i can now get the variable product reference for the first product i am on, but if i change page and open the iframe form, the reference of the previous product is there... no way, i have to manually delete it and reload the page to get the new page product reference...

    it makes me crazy...i've been looking for a solution searching and googling without any result...

    somebody can point me to the solution?

    thanks in advance

    mario

  • Profile Image
    JotForm Support

    Answered by Welvin on July 18, 2015 at 02:47 PM

    Hi Mario,

    I can't seem to find a solution for this matter. The only workaround I can offer is to let your customer edit the product reference then advise them to change the value whenever they change the product or go into another product page. 

    Maybe, you should also ask Prestashop support about this matter to see if they can help.

    Thanks