• Resolved mlarge

    (@mlarge)


    I set up 8 product pages through WooCommerce. Then I set up a calculator with two number fields that the user will enter. The user will hit next to be presented with their specific custom product (1 of 8) depending on what the user enters. OR I need the next button to show the price of that particular product to then BUY it. Is this possible? Or is there another solution to show 1 of 8 prices based off the two number fields? I tried the hide/show function but it’s not working. Is there a way to have the BUY button take them to a specific URL (Product Page) based off the input of the two number fields? Please help!!!

    https://www.ads-software.com/plugins/calculated-fields-form/

Viewing 15 replies - 16 through 30 (of 43 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    The easier solution would be the implementation of a multi-pages form. To generate a form with multiple pages, you simply should insert a “Page Break” field between the fields that belong to a page and another.

    However, if you want to use the values submitted by a form in another form (inserted in a different page), the process is more complex, please, visit the following link to our technical blog that illustrates the process:

    https://blog.net-factor.com/how-to-use-the-data-submitted-by-a-form-in-another-one/

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    Hi, I’m having issues trying to import data into another form field. The above is for the Thank you page only. My form redirects to several pages. Do you have a solution for this type of integration?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I’m sorry, but the forms are redirected to only one page, and then in this page you can decide if redirect the user to a different page. A form can not be submitted to multiple pages.

    For example, you can create a thank you page, and in the thank you page, it is possible to insert the shortcode:

    [CP_CALCULATED_FIELDS_RESULT]
    ...
    [/CP_CALCULATED_FIELDS_RESULT]

    and replace the symbols “…” by a javascript code that redirects to the user to another page:

    <script>
    document.location.href='https://www.url-to-the-other-page.com';
    </script>

    and in the other page, inserts another pair of shortcodes, to use the values of submitted information by the original form.

    In the <script></script> tags you can check the values of the submitted information for redirecting to a page or another.

    For example, suppose the fieldname4 field can be 0 or 1, and if the value of fieldname4 is 0, the user should be redirected to https://www.website.com/page-0.html, and if the value of fieldname4 is 1 the user should be redirected to https://www.website.com/page-1.html, for this example the shortcode to insert in the thank you page, associated to the form, would be:

    [CP_CALCULATED_FIELDS_RESULT]
    <script>
    var v = <%fieldname4_value%>;
    document.location.href = (v == 0 ) ? 'https://www.website.com/page-0.html' : https://www.website.com/page-1.html;
    </script>
    [/CP_CALCULATED_FIELDS_RESULT]

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    I have a form on one page of my site that contains the code below. I have another form on one of the redirect pages below. I would like to import the data from the first form (fieldname1 and fieldname2) into the new form on the redirect page. Is that possible?

    (function(){
    var a = fieldname1;
    var b = fieldname2;

    if(a == 1 && b == 1) document.location.href = ‘https://www.yourdomain.com/product1.html&#8217;;

    if(a == 1 && b == 2) document.location.href = ‘https://www.yourdomain.com/product2.html&#8217;;

    if(a == 2 && b == 1) document.location.href = ‘https://www.yourdomain.com/product3.html&#8217;;

    if(a == 2 && b == 2) document.location.href = ‘https://www.yourdomain.com/product4.html&#8217;;
    })();

    Thread Starter mlarge

    (@mlarge)

    So, the following redirects do not take you to a Thank you page at all. It takes you to one of the redirect pages. So, can i import the code you stated above into one of the redirect pages or would there be a special code to insert into the two fields in the redirect page?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    You should to understand how the plugin works.

    After submit a form, the plugin creates a session variable with the id of the row where the data were stored, and then, if you insert the shortcodes:

    [CP_CALCULATED_FIELDS_RESULT]
    ...
    [/CP_CALCULATED_FIELDS_RESULT]

    In a page visited after submit the form, you will have access to the submitted information, so, you can use the shortcodes in the pages where the users are redirected.

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    My form does not use the “Submit” button. My form uses a calculate button labeled. I have the calculated field telling the button to redirect to one of 8 URL’s depending on user input for two number fields. So, I can’t really follow the instructions above if I’m not using the “Submit” button. I tried to use the shortcode above within the redirect pages and it doesn’t work. Is there another solution for my calculation?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    You cannot use the information entered by the users in a form, without submit the form.

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    What if I put this code in the onclick event of the calculate button?
    jQuery(this).closest(‘form’).submit();

    Plugin Author codepeople

    (@codepeople)

    Hi,

    If you are using the Pro or Developer versions of the plugin, you can submit the form with the javascript code in the onclick event of button, but you should redirect to the user to the correct page, from the thank you page associated to the form, as I’ve explained in the previous entries.

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    I am using the developer version of the plugin. So sorry but this is all new to me so I’m trying to understand the process. I removed the code from the calculator and it now submits to a “Thank you” page. I inserted the javascript code below into the Thank you page but it does not work. It just stays on the Thank you page and doesn’t redirect to the specific URL’s according to the user input of the two fields. Also, would the value code now show in the URL’s below if i place new result fields in the pages?

    [CP_CALCULATED_FIELDS_RESULT]
    <script>
    (function(){
    var a = <%fieldname2_value%>;
    var b = <%fieldname3_value%>;

    if(a <= 4 && b == 1) document.location.href = ‘/product-1/’;
    if(a >= 5 && a <= 9 && b == 1) document.location.href = ‘/product2.html’;
    if(a >= 10 && a <= 15 && b == 1) document.location.href = ‘/product3.html’;
    if(a >= 16 && a <= 30 && b == 1) document.location.href = ‘/product4.html’;

    if(a <= 4 && b == 0) document.location.href = ‘/product5.html’;
    if(a >= 5 && a <= 9 && b == 0) document.location.href = ‘/product6.html’;
    if(a >= 10 && a <= 15 && b == 0) document.location.href = ‘/product7.html’;
    if(a >= 16 && a <= 30 && b == 0) document.location.href = ‘/product8.html’;

    if(a >= 31 && b >= 0) document.location.href = ‘/rep-form/’;

    if(a <= 4 && b >= 2) document.location.href = ‘/rep-form/’;
    if(a >= 5 && a <= 9 && b >= 2) document.location.href = ‘/rep-form/’;
    if(a >= 10 && a <= 15 && b >= 2) document.location.href = ‘rep-form/’;
    if(a >= 16 && a <= 30 && b >= 2) document.location.href = ‘/rep-form/’;

    })();
    </script>
    [/CP_CALCULATED_FIELDS_RESULT]

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I’ll need the link to your website to check your code in detail.

    Please, be sure you are using the latest version of the plugin.

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    sure, this is the link

    Plugin Author codepeople

    (@codepeople)

    Hi,

    The issue is simple, wpautop function of WordPress is replacing the changes of lines by tags: <p></p>, to prevent that WordPress modifies your code, insert it in the following way (pays attention to the use of the tags <pre></pre>):

    [CP_CALCULATED_FIELDS_RESULT]
    <pre style="display:none;">
    <script>
    (function(){
    var a = <%fieldname2_value%>;
    var b = <%fieldname3_value%>;
    
    if(a <= 4 && b == 1) document.location.href = '/product-1/';
    if(a >= 5 && a <= 9 && b == 1) document.location.href = '/product2.html';
    if(a >= 10 && a <= 15 && b == 1) document.location.href = '/product3.html';
    if(a >= 16 && a <= 30 && b == 1) document.location.href = '/product4.html';
    
    if(a <= 4 && b == 0) document.location.href = '/product5.html';
    if(a >= 5 && a <= 9 && b == 0) document.location.href = '/product6.html';
    if(a >= 10 && a <= 15 && b == 0) document.location.href = '/product7.html';
    if(a >= 16 && a <= 30 && b == 0) document.location.href = '/product8.html';
    
    if(a >= 31 && b >= 0) document.location.href = '/rep-form/';
    
    if(a <= 4 && b >= 2) document.location.href = '/rep-form/';
    if(a >= 5 && a <= 9 && b >= 2) document.location.href = '/rep-form/';
    if(a >= 10 && a <= 15 && b >= 2) document.location.href = 'rep-form/';
    if(a >= 16 && a <= 30 && b >= 2) document.location.href = '/rep-form/';
    
    })();
    </script>
    </pre>
    [/CP_CALCULATED_FIELDS_RESULT]

    Best regards.

    Thread Starter mlarge

    (@mlarge)

    Yes, that worked perfectly. Thanks so much for your help. I have the calculated field results on the redirect pages but it displays in text view. Is there a way to get the results to display in a field? The result for the fieldname 2 is “2” and displays like the below. Can I get that result in a field?

    setFieldValue(‘fieldname3_1′, ‘2‘ );

Viewing 15 replies - 16 through 30 (of 43 total)
  • The topic ‘Link to a specific WooCommerce product page based off user input’ is closed to new replies.