Cant get the current postcode The Next CEO of Stack Overflowjquery ajax callback gets null dataGet the current page url in Magento 2.0Get current currency symbol in Magento2Get current theme in magento 2Magento 2 Checkout Missing Postcodeget subtotal value in magento 2.2How to get access token using oauth_consumer_key in Magento 2?Getting error 'Area is already set' while changing theme for Magento 2.2.4Magento 2 Amasty Layered Navigation. Remove display of current applied filtersGet Category URL multistore and multisite

Grabbing quick drinks

0 rank tensor vs 1D vector

How to check if all elements of 1 list are in the *same quantity* and in any order, in the list2?

How to avoid supervisors with prejudiced views?

Why does standard notation not preserve intervals (visually)

Domestic-to-international connection at Orlando (MCO)

Reference request: Grassmannian and Plucker coordinates in type B, C, D

A Man With a Stainless Steel Endoskeleton (like The Terminator) Fighting Cloaked Aliens Only He Can See

Is it okay to majorly distort historical facts while writing a fiction story?

Prepend last line of stdin to entire stdin

Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?

Writing differences on a blackboard

Proper way to express "He disappeared them"

Solving system of ODEs with extra parameter

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Would be okay to drive on this tire?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Can we say or write : "No, it'sn't"?

WOW air has ceased operation, can I get my tickets refunded?

Is there a way to save my career from absolute disaster?

Why didn't Khan get resurrected in the Genesis Explosion?

How to install OpenCV on Raspbian Stretch?

Rotate a column



Cant get the current postcode



The Next CEO of Stack Overflowjquery ajax callback gets null dataGet the current page url in Magento 2.0Get current currency symbol in Magento2Get current theme in magento 2Magento 2 Checkout Missing Postcodeget subtotal value in magento 2.2How to get access token using oauth_consumer_key in Magento 2?Getting error 'Area is already set' while changing theme for Magento 2.2.4Magento 2 Amasty Layered Navigation. Remove display of current applied filtersGet Category URL multistore and multisite










0















im having some issues getting the current or changed postcode from checkout input postcode and also trying to fired again the method from my component "getKiosPoints".



Basically the work flow is to check if a postcode is filled in the input, and if it is use it to make a call to a API to get the locations.



This works fine when the page is loaded with the information of postcode filled.



The problem is to get the postcode when is changed in the page, and than fire the method 'getKiospoints' with the postcoded that was inserted.



I was using the "quote.shippingAddress._latestValue.postcode" or the "quote.shippingAddress().postcode", but the problem is since is going to get in the storage, i always get the previous postcoded and not the actual that was just inserted.



Here is my code:



define([
'jquery',
'ko',
'Magento_Checkout/js/model/quote',
'uiComponent'
], function ($,ko,quote,Component)
'use strict';

var listLocations = ko.observableArray([]);



$(document).on('change',"[name='postcode']",function()
console.log("what postcalcode");
console.log(quote.shippingAddress().postcode);
);



return Component.extend(
defaults:
template: 'Cloud_Vasp/checkout/shipping/pickup-points'
,
getCode: function()
return 'cloud_vasp_cloud_vasp';
,
initObservable: function ()
this._super();

this.selectedMethod = ko.computed(function()
var method = quote.shippingMethod();
var selectedMethod = method != null ? method.carrier_code + '_' + method.method_code : null;
return selectedMethod;
, this);

return this;
,
getKiosPoints: function ()

var postalCode = quote.shippingAddress._latestValue.postcode;

console.log(postalCode);
$.ajax
(
type: "POST",
beforeSend: function (xhr)
xhr.setRequestHeader('Authorization', 'Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDc');
,
url: '...api/va.pt/GetServiceDeliveryPoints',
dataType: 'json',
contentType: 'application/json',

async: true,
//json object to sent to the authentication url
data: JSON.stringify(
"PostalCodeOrLocality": postalCode

),
success: function (data)
if(data.statusCode == 200)

var locations = data.response;
listLocations(data.response);


//return locations;

,
error: function( jqXhr, textStatus, errorThrown )
return errorThrown;

)

return listLocations;



);
);


Am i missing something?










share|improve this question


























    0















    im having some issues getting the current or changed postcode from checkout input postcode and also trying to fired again the method from my component "getKiosPoints".



    Basically the work flow is to check if a postcode is filled in the input, and if it is use it to make a call to a API to get the locations.



    This works fine when the page is loaded with the information of postcode filled.



    The problem is to get the postcode when is changed in the page, and than fire the method 'getKiospoints' with the postcoded that was inserted.



    I was using the "quote.shippingAddress._latestValue.postcode" or the "quote.shippingAddress().postcode", but the problem is since is going to get in the storage, i always get the previous postcoded and not the actual that was just inserted.



    Here is my code:



    define([
    'jquery',
    'ko',
    'Magento_Checkout/js/model/quote',
    'uiComponent'
    ], function ($,ko,quote,Component)
    'use strict';

    var listLocations = ko.observableArray([]);



    $(document).on('change',"[name='postcode']",function()
    console.log("what postcalcode");
    console.log(quote.shippingAddress().postcode);
    );



    return Component.extend(
    defaults:
    template: 'Cloud_Vasp/checkout/shipping/pickup-points'
    ,
    getCode: function()
    return 'cloud_vasp_cloud_vasp';
    ,
    initObservable: function ()
    this._super();

    this.selectedMethod = ko.computed(function()
    var method = quote.shippingMethod();
    var selectedMethod = method != null ? method.carrier_code + '_' + method.method_code : null;
    return selectedMethod;
    , this);

    return this;
    ,
    getKiosPoints: function ()

    var postalCode = quote.shippingAddress._latestValue.postcode;

    console.log(postalCode);
    $.ajax
    (
    type: "POST",
    beforeSend: function (xhr)
    xhr.setRequestHeader('Authorization', 'Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDc');
    ,
    url: '...api/va.pt/GetServiceDeliveryPoints',
    dataType: 'json',
    contentType: 'application/json',

    async: true,
    //json object to sent to the authentication url
    data: JSON.stringify(
    "PostalCodeOrLocality": postalCode

    ),
    success: function (data)
    if(data.statusCode == 200)

    var locations = data.response;
    listLocations(data.response);


    //return locations;

    ,
    error: function( jqXhr, textStatus, errorThrown )
    return errorThrown;

    )

    return listLocations;



    );
    );


    Am i missing something?










    share|improve this question
























      0












      0








      0








      im having some issues getting the current or changed postcode from checkout input postcode and also trying to fired again the method from my component "getKiosPoints".



      Basically the work flow is to check if a postcode is filled in the input, and if it is use it to make a call to a API to get the locations.



      This works fine when the page is loaded with the information of postcode filled.



      The problem is to get the postcode when is changed in the page, and than fire the method 'getKiospoints' with the postcoded that was inserted.



      I was using the "quote.shippingAddress._latestValue.postcode" or the "quote.shippingAddress().postcode", but the problem is since is going to get in the storage, i always get the previous postcoded and not the actual that was just inserted.



      Here is my code:



      define([
      'jquery',
      'ko',
      'Magento_Checkout/js/model/quote',
      'uiComponent'
      ], function ($,ko,quote,Component)
      'use strict';

      var listLocations = ko.observableArray([]);



      $(document).on('change',"[name='postcode']",function()
      console.log("what postcalcode");
      console.log(quote.shippingAddress().postcode);
      );



      return Component.extend(
      defaults:
      template: 'Cloud_Vasp/checkout/shipping/pickup-points'
      ,
      getCode: function()
      return 'cloud_vasp_cloud_vasp';
      ,
      initObservable: function ()
      this._super();

      this.selectedMethod = ko.computed(function()
      var method = quote.shippingMethod();
      var selectedMethod = method != null ? method.carrier_code + '_' + method.method_code : null;
      return selectedMethod;
      , this);

      return this;
      ,
      getKiosPoints: function ()

      var postalCode = quote.shippingAddress._latestValue.postcode;

      console.log(postalCode);
      $.ajax
      (
      type: "POST",
      beforeSend: function (xhr)
      xhr.setRequestHeader('Authorization', 'Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDc');
      ,
      url: '...api/va.pt/GetServiceDeliveryPoints',
      dataType: 'json',
      contentType: 'application/json',

      async: true,
      //json object to sent to the authentication url
      data: JSON.stringify(
      "PostalCodeOrLocality": postalCode

      ),
      success: function (data)
      if(data.statusCode == 200)

      var locations = data.response;
      listLocations(data.response);


      //return locations;

      ,
      error: function( jqXhr, textStatus, errorThrown )
      return errorThrown;

      )

      return listLocations;



      );
      );


      Am i missing something?










      share|improve this question














      im having some issues getting the current or changed postcode from checkout input postcode and also trying to fired again the method from my component "getKiosPoints".



      Basically the work flow is to check if a postcode is filled in the input, and if it is use it to make a call to a API to get the locations.



      This works fine when the page is loaded with the information of postcode filled.



      The problem is to get the postcode when is changed in the page, and than fire the method 'getKiospoints' with the postcoded that was inserted.



      I was using the "quote.shippingAddress._latestValue.postcode" or the "quote.shippingAddress().postcode", but the problem is since is going to get in the storage, i always get the previous postcoded and not the actual that was just inserted.



      Here is my code:



      define([
      'jquery',
      'ko',
      'Magento_Checkout/js/model/quote',
      'uiComponent'
      ], function ($,ko,quote,Component)
      'use strict';

      var listLocations = ko.observableArray([]);



      $(document).on('change',"[name='postcode']",function()
      console.log("what postcalcode");
      console.log(quote.shippingAddress().postcode);
      );



      return Component.extend(
      defaults:
      template: 'Cloud_Vasp/checkout/shipping/pickup-points'
      ,
      getCode: function()
      return 'cloud_vasp_cloud_vasp';
      ,
      initObservable: function ()
      this._super();

      this.selectedMethod = ko.computed(function()
      var method = quote.shippingMethod();
      var selectedMethod = method != null ? method.carrier_code + '_' + method.method_code : null;
      return selectedMethod;
      , this);

      return this;
      ,
      getKiosPoints: function ()

      var postalCode = quote.shippingAddress._latestValue.postcode;

      console.log(postalCode);
      $.ajax
      (
      type: "POST",
      beforeSend: function (xhr)
      xhr.setRequestHeader('Authorization', 'Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDc');
      ,
      url: '...api/va.pt/GetServiceDeliveryPoints',
      dataType: 'json',
      contentType: 'application/json',

      async: true,
      //json object to sent to the authentication url
      data: JSON.stringify(
      "PostalCodeOrLocality": postalCode

      ),
      success: function (data)
      if(data.statusCode == 200)

      var locations = data.response;
      listLocations(data.response);


      //return locations;

      ,
      error: function( jqXhr, textStatus, errorThrown )
      return errorThrown;

      )

      return listLocations;



      );
      );


      Am i missing something?







      magento knockout.js magento2 magento2.2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 15:46









      CodeJamCodeJam

      275




      275






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I have another suggestion. You can use onepage.html and apply the following code :-



          require(
          [
          'jquery',
          'Magento_Checkout/js/model/quote',
          'Magento_Checkout/js/model/shipping-service',
          'Magento_Checkout/js/model/shipping-rate-registry',
          'Magento_Checkout/js/model/shipping-rate-processor/new-address',
          'Magento_Checkout/js/model/shipping-rate-processor/customer-address',
          'Magento_Customer/js/model/customer'
          ],
          function ($, quote, shippingService, rateRegistry, defaultProcessor, customerAddressProcessor, customer)

          $(document).on('change',"#shipping-new-address-form [name='postcode']",function(e)

          var elementValue = $(this).val();
          //Apply your code here

          );

          );





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f55066595%2fcant-get-the-current-postcode%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














            I have another suggestion. You can use onepage.html and apply the following code :-



            require(
            [
            'jquery',
            'Magento_Checkout/js/model/quote',
            'Magento_Checkout/js/model/shipping-service',
            'Magento_Checkout/js/model/shipping-rate-registry',
            'Magento_Checkout/js/model/shipping-rate-processor/new-address',
            'Magento_Checkout/js/model/shipping-rate-processor/customer-address',
            'Magento_Customer/js/model/customer'
            ],
            function ($, quote, shippingService, rateRegistry, defaultProcessor, customerAddressProcessor, customer)

            $(document).on('change',"#shipping-new-address-form [name='postcode']",function(e)

            var elementValue = $(this).val();
            //Apply your code here

            );

            );





            share|improve this answer



























              0














              I have another suggestion. You can use onepage.html and apply the following code :-



              require(
              [
              'jquery',
              'Magento_Checkout/js/model/quote',
              'Magento_Checkout/js/model/shipping-service',
              'Magento_Checkout/js/model/shipping-rate-registry',
              'Magento_Checkout/js/model/shipping-rate-processor/new-address',
              'Magento_Checkout/js/model/shipping-rate-processor/customer-address',
              'Magento_Customer/js/model/customer'
              ],
              function ($, quote, shippingService, rateRegistry, defaultProcessor, customerAddressProcessor, customer)

              $(document).on('change',"#shipping-new-address-form [name='postcode']",function(e)

              var elementValue = $(this).val();
              //Apply your code here

              );

              );





              share|improve this answer

























                0












                0








                0







                I have another suggestion. You can use onepage.html and apply the following code :-



                require(
                [
                'jquery',
                'Magento_Checkout/js/model/quote',
                'Magento_Checkout/js/model/shipping-service',
                'Magento_Checkout/js/model/shipping-rate-registry',
                'Magento_Checkout/js/model/shipping-rate-processor/new-address',
                'Magento_Checkout/js/model/shipping-rate-processor/customer-address',
                'Magento_Customer/js/model/customer'
                ],
                function ($, quote, shippingService, rateRegistry, defaultProcessor, customerAddressProcessor, customer)

                $(document).on('change',"#shipping-new-address-form [name='postcode']",function(e)

                var elementValue = $(this).val();
                //Apply your code here

                );

                );





                share|improve this answer













                I have another suggestion. You can use onepage.html and apply the following code :-



                require(
                [
                'jquery',
                'Magento_Checkout/js/model/quote',
                'Magento_Checkout/js/model/shipping-service',
                'Magento_Checkout/js/model/shipping-rate-registry',
                'Magento_Checkout/js/model/shipping-rate-processor/new-address',
                'Magento_Checkout/js/model/shipping-rate-processor/customer-address',
                'Magento_Customer/js/model/customer'
                ],
                function ($, quote, shippingService, rateRegistry, defaultProcessor, customerAddressProcessor, customer)

                $(document).on('change',"#shipping-new-address-form [name='postcode']",function(e)

                var elementValue = $(this).val();
                //Apply your code here

                );

                );






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 11 at 7:00









                Rakesh JakharRakesh Jakhar

                43638




                43638





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f55066595%2fcant-get-the-current-postcode%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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                    How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page