Skip to content

How to move field on onestepcheckout to another fieldset that is not there by default?

There is a onestepcheckout that is being processed by two modules.
One has most of the wrappers and templates, and another one is responsible for shipping (specific courier company for a country). Both modules have their xml checkout layouts and I need to move the field that is set by the one that does the shipping.

I need to move the city field from the shipping address fieldset to shippingAdditional (with street, house num, etc). The issue is that shippingAdditional renders only if you choose shipping method, thus making layoutproccesor not a feasible solution. Meaning, I can make it move there when the target fieldset appears, but until then, the city field will appear in the original place.

How to do it correctly? Should I remove the field completely and then reinsert it with js mixin?

Now that i think of it, if I remove the field, its JS component won’t be initialized, therefore mixin won’t even load.
I have no idea what to do…

city.js has this function

selectedMethod: function () {
            var method = quote.shippingMethod();
            var selectedMethodCode = method != null ? method.method_code : false;
            if (selectedMethodCode === 'c2w' || selectedMethodCode === 'w2w' || selectedMethodCode === 'w2c' || selectedMethodCode === 'c2c') {
                this.cityDefaultVisible(false);
                this.visible(true);
            } else {
                this.cityDefaultVisible(true);
                this.visible(false);
            }
            return selectedMethodCode;
        }