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, 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:

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

but this does not seem to work.

General Grievance
4531 gold badge7 silver badges12 bronze badges
asked Sep 14, 2017 at 8:57

2 Answers 2

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');
 });
 });
answered Apr 17, 2018 at 20:31
0

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

$('input[name="shippingAddress.city"]').val("My city").keyup();
answered Feb 17, 2020 at 9:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.