0

Is it possible to just fill the shipping address fields with my own values?

For example: I want city field to be filled with My City when an event occurs on the checkout page. I know the checkout page uses Knockout JS that but I haven't figured out how to pass values to the fields themselves.

So far I have jquery running on the checkout page but writing code like:

$('input[name="shippingAddress.city"]').val("My city");

This does not work.

I appreciate any help that anyone can give.

Thanks.

0

Yes, It is possible. It works fine in my case.

require(['jquery'], function($){

    var onDomIsRendered = function(domString) {
          return new Promise(function(resolve, reject) {
            function waitUntil() {
              setTimeout(function() {
                if($(domString).length > 0){
                  resolve($(domString));
                }else {
                  waitUntil();
                }
              }, 4000);
            }
            //start the loop
            waitUntil();
          });
        };

        onDomIsRendered("#shipping-new-address-form").then(function(element){               
            $('[name="city"]').val('My city');
        });
    });
| improve this answer | |
0

Because Shipping address from update value by event keyup so you can try:

$('input[name="shippingAddress.city"]').val("My city").keyup();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.