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

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived