Hello all I am trying to get selected shipping address from dropdown(without changing the dropdown option like getting selected shipping address when page loads) or default shipping address on checkout page. On implementing my functionality in


define(['Magento_Checkout/js/model/quote', 'jquery',
'mage/translate',], function (quote,$) {
    'use strict';

    var mixin = {

        isPickup: function() {
            var shippingMethod = quote.shippingMethod();
            if (shippingMethod === null || shippingMethod === undefined) {
                return false;
            if (shippingMethod.carrier_title === null || shippingMethod.carrier_title === undefined) {
                return false;
            return (shippingMethod.carrier_title === "Toronto Customer pick-up");

    return function (target) {
        /**Code below checks if the default shipping address or the slected shipping address has pobox in dropdwon shipping address select on Checkout page*/
        var convertstreet = quote.shippingAddress().street.toString();
        var pattern = /((((p[\s\.]?)\s?[o\s][\.]?)\s?)|(post\s?office\s?))((box|bin|b\.?)?\s?((num|number|no|#)\.?)?\s?\d+)/igm.test(convertstreet);

        if(pattern== false)
         return target.extend(mixin);

But I am getting an error saying Uncaught TypeError: Cannot read property 'street' of null on (var convertstreet = quote.shippingAddress().street.toString();).

I am not sure is this the best way to get the street address from quote but I am still trying to figure out any better solution to get the street address from either default shipping address or selected shipping address from dropdown(without changing the dropdown option like getting selected shipping address when page loads). It would be really helpful if I can get some advice or suggestion so that I can understand the concept how quote works? thanks

2 Answers 2


Late answer but might help someone else, just add the check above your code like if(quote.shippingAddress() !== null) and put your code inside it. Hopefully, It'll avoid the error you're getting.


I have a suggestion for you, we can get street:


It's an array.

  • I tried above solution but its still says null.
    – J. Doe
    Commented Nov 20, 2019 at 13:18
  • I have don't have those addresses set as shipping or billing its coming from magento backend and I have same shipping address and billing address which is not present in the list. The select shipping address droplist has around 200 addresses except for the default shipping address. I hope it makes sense. So I just want the selected address from dropdown on page loads for the first time. I am still trying to figure out if I am missing something.
    – J. Doe
    Commented Nov 20, 2019 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.