As previously announced via banners and our newsletters, support is no longer available through this platform.

For easier navigation, you can still click on "Submit a Ticket" here, choose the appropriate category, and you'll be redirected to the correct support channel for your plugin.

You can still access your previous tickets and browse public tickets, but please note that responding to tickets is no longer possible.

Paid customers: Please log in to your store account for support.

Pre-purchase questions: Use the support widget in the bottom-right corner of our websites:
https://wpamelia.com
https://wpdatatables.com
https://wpreportbuilder.com

Okay
  Public Ticket #2735276
Questions about using GET Parameters with Amelia's cutom fields
Closed

Comments

  •  2
    Polaris Media GmbH started the conversation

    How can we pass a URL-GET parameter to a custom field in Amelias booking form as plain text? E.g. we'd like to pass a plain text info inside an a-tag into a custom field inside Amelia's booking process like this:

    <a href="/amelia/booking.html?mycustomfield=Some%20Text">I want to collect this</a>

    Is this possible?

    Also, would it be possible to pass a price for a service the same way, or is it impossible to set a price dynamically?

    Best wishes

  •  2,576
    Aleksandar replied

    Hello there.

    This falls under custom work, so I can only offer some advice about this. Please take a look at this example:

    <script>
      var getUrlParams = function (url) {
        var params = {};
        var parser = document.createElement('a');
        parser.href = url;
        var query = parser.search.substring(1);
        var vars = query.split('&');
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split('=');
          params[pair[0]] = decodeURIComponent(pair[1]);
        }
        return params;
      };
      window.urlParams = getUrlParams(window.location.href);
      window.beforeConfirmBookingLoaded = function () {
        var firstName = document.querySelector("#am-confirm-booking > div:nth-child(1) > form > div.am-confirm-booking-data.el-row > div:nth-child(3) > div > div > div > input");
        var lastName = document.querySelector("#am-confirm-booking > div:nth-child(1) > form > div.am-confirm-booking-data.el-row > div:nth-child(4) > div > div > div > input");
        if ('firstName' in window.urlParams) {
          firstName.value = window.urlParams.firstName;
          firstName.dispatchEvent(new Event('input'));
        }
        if ('lastName' in window.urlParams) {
          lastName.value = window.urlParams.lastName;
          lastName.dispatchEvent(new Event('input'));
        }
      }
    </script>

    It uses our JS hook to modify the value of first name and last name through URL, or to use our email notification placeholders in the URL.

    For example:

    https://localhost/ameliafull/index.php/booking/?firstName=John&lastName=Doe - this will add "John" in the First Name field, and "Doe" in the Last Name field.

    https://localhost/ameliafull/index.php/booking/?firstName=%customer_first_name%&lastName=%customer_last_name% this will add both the name and the last name of the customer, pulling it from our database if they're logged in.

    You can modify the JS to do something similar with custom field values. You can target the class "cf-ID".

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables