Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Sinisa Bajic – bajs

    (@bajsolinowich)

    This is solved by myself.

    I fetched the query strings, stored them in variables and then after the iframe is loaded added the values to correspondent fields.

    Cheers!

    Plugin Support mbrsolution

    (@mbrsolution)

    That is great news ??

    You might like to share your solution for others.

    Kind regards

    Thread Starter Sinisa Bajic – bajs

    (@bajsolinowich)

    Sure.

    
    // Fetch Query Strings
    jQuery(document).ready(function($){
      function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, '\\$&');
        let regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, ' '));
      }
    
    //Store them in variables
      let total = getParameterByName('total');
      let email = getParameterByName('email');
      let full_name = getParameterByName('full_name');
    
    /* 
    Since I have different scenarios
    and multiple forms (product shortcodes) on single page
    I am showing different form based on total amount 
    and want the form to open automatically
    */
    
    if (total == 165.00) {
    setTimeout(function() {
            $(".first-product-class").trigger('click');
               $(".asp-popup-iframe").load (function(){
               $('.asp-popup-iframe').contents().find('#email').attr('value', email);
              $('.asp-popup-iframe').contents().find('#billing-name').attr('value', full_name);
            });
        },10);
    }
    
    else if...
    
    });
    
    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you very much ??

    I am sure this will help those with the same requirements.

    Enjoy the plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Prepopulate Form With Query String Parameters’ is closed to new replies.