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

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form