• Hello,

    I have created a city field in a caldera form and wanted to autopopulate it with Woocommerce’s city field.

    For that, I used:

    <script>
    jQuery(document).ready(function($) {
    jQuery('#fld_9255841_1').keyup(function(){
        var fName = jQuery('#fld_9255841_1').val();
    
        var cmpName = fName;
        jQuery('#billing_city_field').val(cmpName);    
    
    });
    </script>

    In the above code #fld_9255841_1 is the caldera’s field and #billing_city_field is the Woocommerce’s default field. I thought it would autopopulate if an existing user fills the form, but it is not.

    Could any one help me? I tried to use the snippet in theme’s file and in caldera’s html field. No luck in the both ways.

    I was unsuccessful with the system tags though. Any help is appreciated.

    https://www.ads-software.com/plugins/caldera-forms/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Josh Pollock

    (@shelob9)

    What is the city field? Is it a meta field? If so, I wouldn’t use jQuery for this. I’d do it server side, as explained here https://calderawp.com/doc/customizing-auto-populated-field-options-in-caldera-forms/

    Thread Starter vbk100

    (@vbk100)

    Unfortunately, it is not a meta field.

    It is the Woocommerce checkout’s “billing_city” field.

    Plugin Author Josh Pollock

    (@shelob9)

    Interesting. Can I ask for a little more information on what is going on here, and what the goal is? Seems like there must be a better way to do this. Are you creating a Woo checkout with Caldera Forms, or trying to sync data between two forms on the same page?

    Thread Starter vbk100

    (@vbk100)

    Hello Josh,

    Thanks a lot for your cooperation.

    I am keeping the checkout page as it is and using a new Caldera Form to collect details with more than a dozen fields from visitors/users. The will have fields like User address,location, Phone number, email address and more. Woocommerce’s checkout page has the same options (I have made these woocommerce’s fields as optional (default is “required”)) and I don’t want the users to type the same details in two places (in my setup users/visitors enter details in a form and on it’s submission a product will automatically be added to cart and they will directly redirect to the checkout page). Like this, I have multiple forms for multiple products.

    By the way, they are not in a same page. Caldera form is in different page.

    In simple words, yes I am tryiing to sync data between Caldera and Woocommerce checkout page so that the logged in users need not fill these fields in caldera form and new visitors need not fill woocommerce checkout fields. Please let me know how can I proceed further.

    Plugin Author Josh Pollock

    (@shelob9)

    If the forms are not on the same page, then you can’t use the strategy you showed in your initial post. That would only work if both forms were on the same page.

    Instead you are going to have to make which ever form runs first either pass GET variables in the URL that can be read by the second form, or save the data in the database and then use that data to set the defaults of the form.

    On the GET variable strategy:
    If the Caldera Form runs first, you can use passback variables to add GET vars to the URL the redirect processor passes. Using those in your WooCommerce form is going to be a bit of a pain, as parsing query strings in JavaScript isn’t easy.

    If the WooCommerce form runs first, not sure how your going to get it to pass the GET variables to the next session, but making them field defaults in Caldera Forms is easy, using {get:*} magic tags.

    On the save data between sessions in the database strategy:
    I can show you the filters to set Caldera Forms default fields from values in the DB/ transients etc, but I don’t know enough about WooCommerce to give you enough advice to make this work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Populating Caldera Form Fields with WooCommerce Checkout Fields’ is closed to new replies.