Magento 2 manipulate shipping address fields in chekout via knockout.jsMagento 2: How to set Max Length for Street Address?Merge billing address, shipping address and shipping method on onepageSet Shipping Address via Magento 2 REST APIMagento 2 - Save custom shipping address' fields to quote_address tableMagento2: switch shipping methods placement with address fieldsShipping Address validationMagento 2: Export Order Shipping Address As Separate FieldsRemove street address field and required attribute from shipping addressMagento 2 how to billing address fields under shipping address in shipping pagemagento 2 add custom fields to checkout form below shipping address formShipping address edit content not loading in fields Magento 2

You have no, but can try for yes

Why teach C using scanf without talking about command line arguments?

Does the Bracer of Flying Daggers really let a thief make 4 attacks per round?

Function over a list that depends on the index

Tricky interview question for mid-level C++ developer

Should I work for free if client's requirement changed

Company looks for long-term employees, but I know I won't be interested in staying long

How electronics on board of JWST can survive the low operating temperature while it's difficult to survive lunar night?

Is it possible to have a career in SciComp without contributing to arms research?

The most secure way to handle someone forgetting to verify their account?

Should I have shared a document with a former employee?

I want light controlled by one switch, not two

What could make large expeditions ineffective for exploring territory full of dangers and valuable resources?

Making a Dataset that emulates `ls -tlra`?

What is a Kravchuk transform and how is it related to Fourier transforms?

What's the largest an Earth-like planet can be and support Earth's biosphere?

Brute-force the switchboard

Linux ext4 restore file and directory access rights after bad backup/restore

When we are talking about black hole evaporation - what exactly happens?

Why isn't a binary file shown as 0s and 1s?

Three Subway Escalators

To what extent does asymmetric cryptography secure bitcoin transactions?

Inscriptio Labyrinthica

How did Jayne know when to shoot?



Magento 2 manipulate shipping address fields in chekout via knockout.js


Magento 2: How to set Max Length for Street Address?Merge billing address, shipping address and shipping method on onepageSet Shipping Address via Magento 2 REST APIMagento 2 - Save custom shipping address' fields to quote_address tableMagento2: switch shipping methods placement with address fieldsShipping Address validationMagento 2: Export Order Shipping Address As Separate FieldsRemove street address field and required attribute from shipping addressMagento 2 how to billing address fields under shipping address in shipping pagemagento 2 add custom fields to checkout form below shipping address formShipping address edit content not loading in fields Magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















i already know how to add new field to shipping address form in checkout, but i need to modify the behavior of some fields. For example:



  • there is a checkbox "Deliver to Packing station";

  • if checkbox is selected, "street" fields becomes hidden and not required, but 2 new fields ("Packing station #" and "Post #") becomes visible and required.

I completely stuck with that. I'm not very familiar with knockout, just have read some lessons on it.
Any help/ideas? (except "go learn knockout.js" :))










share|improve this question






















  • magento.stackexchange.com/questions/148951/…

    – Ankit Shah
    Feb 7 '17 at 9:42







  • 2





    not really what i need. I know how to change form via layout. I need to change it dynamically via js

    – Styopchik
    Feb 7 '17 at 9:49











  • @Styopchik , did you find the solution. Please can you share it here.

    – Sumit Verma
    Jul 11 at 12:07


















3















i already know how to add new field to shipping address form in checkout, but i need to modify the behavior of some fields. For example:



  • there is a checkbox "Deliver to Packing station";

  • if checkbox is selected, "street" fields becomes hidden and not required, but 2 new fields ("Packing station #" and "Post #") becomes visible and required.

I completely stuck with that. I'm not very familiar with knockout, just have read some lessons on it.
Any help/ideas? (except "go learn knockout.js" :))










share|improve this question






















  • magento.stackexchange.com/questions/148951/…

    – Ankit Shah
    Feb 7 '17 at 9:42







  • 2





    not really what i need. I know how to change form via layout. I need to change it dynamically via js

    – Styopchik
    Feb 7 '17 at 9:49











  • @Styopchik , did you find the solution. Please can you share it here.

    – Sumit Verma
    Jul 11 at 12:07














3












3








3








i already know how to add new field to shipping address form in checkout, but i need to modify the behavior of some fields. For example:



  • there is a checkbox "Deliver to Packing station";

  • if checkbox is selected, "street" fields becomes hidden and not required, but 2 new fields ("Packing station #" and "Post #") becomes visible and required.

I completely stuck with that. I'm not very familiar with knockout, just have read some lessons on it.
Any help/ideas? (except "go learn knockout.js" :))










share|improve this question














i already know how to add new field to shipping address form in checkout, but i need to modify the behavior of some fields. For example:



  • there is a checkbox "Deliver to Packing station";

  • if checkbox is selected, "street" fields becomes hidden and not required, but 2 new fields ("Packing station #" and "Post #") becomes visible and required.

I completely stuck with that. I'm not very familiar with knockout, just have read some lessons on it.
Any help/ideas? (except "go learn knockout.js" :))







magento2 onepage-checkout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 7 '17 at 9:30









StyopchikStyopchik

6715 bronze badges




6715 bronze badges












  • magento.stackexchange.com/questions/148951/…

    – Ankit Shah
    Feb 7 '17 at 9:42







  • 2





    not really what i need. I know how to change form via layout. I need to change it dynamically via js

    – Styopchik
    Feb 7 '17 at 9:49











  • @Styopchik , did you find the solution. Please can you share it here.

    – Sumit Verma
    Jul 11 at 12:07


















  • magento.stackexchange.com/questions/148951/…

    – Ankit Shah
    Feb 7 '17 at 9:42







  • 2





    not really what i need. I know how to change form via layout. I need to change it dynamically via js

    – Styopchik
    Feb 7 '17 at 9:49











  • @Styopchik , did you find the solution. Please can you share it here.

    – Sumit Verma
    Jul 11 at 12:07

















magento.stackexchange.com/questions/148951/…

– Ankit Shah
Feb 7 '17 at 9:42






magento.stackexchange.com/questions/148951/…

– Ankit Shah
Feb 7 '17 at 9:42





2




2





not really what i need. I know how to change form via layout. I need to change it dynamically via js

– Styopchik
Feb 7 '17 at 9:49





not really what i need. I know how to change form via layout. I need to change it dynamically via js

– Styopchik
Feb 7 '17 at 9:49













@Styopchik , did you find the solution. Please can you share it here.

– Sumit Verma
Jul 11 at 12:07






@Styopchik , did you find the solution. Please can you share it here.

– Sumit Verma
Jul 11 at 12:07











1 Answer
1






active

oldest

votes


















0














Found solution, here is an example:



define([
'Magento_Ui/js/form/element/single-checkbox'
], function (AbstractField)
'use strict';

return AbstractField.extend(
defaults:
modules:
packing_station_nr: '$ $.parentName .packing_station_nr',
post_nr: '$ $.parentName .post_nr'

,

onCheckedChanged: function ()
this.packing_station_nr().visible(this.checked());
this.post_nr().visible(this.checked());
this._super()



);
);


P.S. this code only toggles fields visibility. Make fields required by default. If field is not visible, validator skips it's validation.






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f158499%2fmagento-2-manipulate-shipping-address-fields-in-chekout-via-knockout-js%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Found solution, here is an example:



    define([
    'Magento_Ui/js/form/element/single-checkbox'
    ], function (AbstractField)
    'use strict';

    return AbstractField.extend(
    defaults:
    modules:
    packing_station_nr: '$ $.parentName .packing_station_nr',
    post_nr: '$ $.parentName .post_nr'

    ,

    onCheckedChanged: function ()
    this.packing_station_nr().visible(this.checked());
    this.post_nr().visible(this.checked());
    this._super()



    );
    );


    P.S. this code only toggles fields visibility. Make fields required by default. If field is not visible, validator skips it's validation.






    share|improve this answer



























      0














      Found solution, here is an example:



      define([
      'Magento_Ui/js/form/element/single-checkbox'
      ], function (AbstractField)
      'use strict';

      return AbstractField.extend(
      defaults:
      modules:
      packing_station_nr: '$ $.parentName .packing_station_nr',
      post_nr: '$ $.parentName .post_nr'

      ,

      onCheckedChanged: function ()
      this.packing_station_nr().visible(this.checked());
      this.post_nr().visible(this.checked());
      this._super()



      );
      );


      P.S. this code only toggles fields visibility. Make fields required by default. If field is not visible, validator skips it's validation.






      share|improve this answer

























        0












        0








        0







        Found solution, here is an example:



        define([
        'Magento_Ui/js/form/element/single-checkbox'
        ], function (AbstractField)
        'use strict';

        return AbstractField.extend(
        defaults:
        modules:
        packing_station_nr: '$ $.parentName .packing_station_nr',
        post_nr: '$ $.parentName .post_nr'

        ,

        onCheckedChanged: function ()
        this.packing_station_nr().visible(this.checked());
        this.post_nr().visible(this.checked());
        this._super()



        );
        );


        P.S. this code only toggles fields visibility. Make fields required by default. If field is not visible, validator skips it's validation.






        share|improve this answer













        Found solution, here is an example:



        define([
        'Magento_Ui/js/form/element/single-checkbox'
        ], function (AbstractField)
        'use strict';

        return AbstractField.extend(
        defaults:
        modules:
        packing_station_nr: '$ $.parentName .packing_station_nr',
        post_nr: '$ $.parentName .post_nr'

        ,

        onCheckedChanged: function ()
        this.packing_station_nr().visible(this.checked());
        this.post_nr().visible(this.checked());
        this._super()



        );
        );


        P.S. this code only toggles fields visibility. Make fields required by default. If field is not visible, validator skips it's validation.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 11 at 13:05









        StyopchikStyopchik

        6715 bronze badges




        6715 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f158499%2fmagento-2-manipulate-shipping-address-fields-in-chekout-via-knockout-js%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?