Magento 2 has NULL value for customer_id in the quotes table, even after the customer is logged in. Causing...

Who is Alexandra K. Trenfor? Did she say the quote?

Retract an already submitted recommendation letter (written for an undergrad student)

Can I criticise the more senior developers around me for not writing clean code?

What is it called when you ride around on your front wheel?

What is /etc/mtab in Linux?

Could moose/elk survive in the Amazon forest?

Is there any hidden 'W' sound after 'comment' in : Comment est-elle?

With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space

Are all CP/M-80 implementations binary compatible?

Why did Israel vote against lifting the American embargo on Cuba?

Flash for group photos near wall

Is Diceware more secure than a long passphrase?

std::is_constructible on incomplete types

What is "leading note" and what does it mean to "raise a note"?

Map material from china not allowed to leave the country

Expansion//Explosion and Siren Stormtamer

Is this homebrew racial feat, Stonehide, balanced?

Does Mathematica have an implementation of the Poisson Binomial Distribution?

Has a Nobel Peace laureate ever been accused of war crimes?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

Does the set of sets which are elements of every set exist?

Error: Syntax error. Missing ')' for CASE Statement

AI positioning circles within an arc at equal distances and heights

Align column where each cell has two decimals with siunitx



Magento 2 has NULL value for customer_id in the quotes table, even after the customer is logged in. Causing error “cartId is a required field”



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraTransactional emails are sent to my client after placing an order, but not to the customers. Why?Quote with no items - add to cart errorGetting strange result querying carts when using multiple search filter groupsAdd validated list of patients to customer account during checkoutMagento 2: Customer is_active field not working?Magento 2: Customer related notifications do not disappear even after refreshing the pageMagento 2: Logged-in customer can't place order with new shipping methodMagento 2.1.7 Upgrade to 2.2.x - Error converting field `value` in table `dgtl_quote_item_option`Error: The configuration parameter “formElement” is a required for “costum_attribute” fieldCron deleting expired quotes





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







1















In a Magento 2 store, the checkout breaks when the user successfully logs in. When the user logs in and enters their address info, they receive no shipping quotes, and an error pops up saying "cartId is a required field".



The error is actually misleading: The underlying problem (discovered using xdebug) is that the quote table row for their cart is missing a customer_id. Instead, it has a NULL value for this field.



This means that:




  1. Magento calls this function


    MagentoQuoteModelResourceModelQuote::loadByCustomerId($quote, $customerId)



    * For the purpose of this example, $customerId = 1;




  2. Which runs a query:


    SELECT `quote`.*
    FROM `quote`
    WHERE ( `quote`.`customer_id` = 1 )
    AND ( store_id IN ( '1' ) )
    AND ( is_active = 1 )
    ORDER BY `updated_at` DESC
    LIMIT 1




  3. Of course, nothing is found, so an exception is thrown. The actual error is masked by a catch-all that does nothing -- the same one described in GitHub Issue #9744

    } catch (NoSuchEntityException $e) {
    /* do nothing and just return null */
    }



So my question is: Why would the quote not have a customer_id for the quote that the customer had created when adding products to the cart? The products still show up in the right sidebar, so the quote is still attached to their session, but for whatever reason, it lacks their customer_id after they log in.










share|improve this question
















bumped to the homepage by Community 3 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    1















    In a Magento 2 store, the checkout breaks when the user successfully logs in. When the user logs in and enters their address info, they receive no shipping quotes, and an error pops up saying "cartId is a required field".



    The error is actually misleading: The underlying problem (discovered using xdebug) is that the quote table row for their cart is missing a customer_id. Instead, it has a NULL value for this field.



    This means that:




    1. Magento calls this function


      MagentoQuoteModelResourceModelQuote::loadByCustomerId($quote, $customerId)



      * For the purpose of this example, $customerId = 1;




    2. Which runs a query:


      SELECT `quote`.*
      FROM `quote`
      WHERE ( `quote`.`customer_id` = 1 )
      AND ( store_id IN ( '1' ) )
      AND ( is_active = 1 )
      ORDER BY `updated_at` DESC
      LIMIT 1




    3. Of course, nothing is found, so an exception is thrown. The actual error is masked by a catch-all that does nothing -- the same one described in GitHub Issue #9744

      } catch (NoSuchEntityException $e) {
      /* do nothing and just return null */
      }



    So my question is: Why would the quote not have a customer_id for the quote that the customer had created when adding products to the cart? The products still show up in the right sidebar, so the quote is still attached to their session, but for whatever reason, it lacks their customer_id after they log in.










    share|improve this question
















    bumped to the homepage by Community 3 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      In a Magento 2 store, the checkout breaks when the user successfully logs in. When the user logs in and enters their address info, they receive no shipping quotes, and an error pops up saying "cartId is a required field".



      The error is actually misleading: The underlying problem (discovered using xdebug) is that the quote table row for their cart is missing a customer_id. Instead, it has a NULL value for this field.



      This means that:




      1. Magento calls this function


        MagentoQuoteModelResourceModelQuote::loadByCustomerId($quote, $customerId)



        * For the purpose of this example, $customerId = 1;




      2. Which runs a query:


        SELECT `quote`.*
        FROM `quote`
        WHERE ( `quote`.`customer_id` = 1 )
        AND ( store_id IN ( '1' ) )
        AND ( is_active = 1 )
        ORDER BY `updated_at` DESC
        LIMIT 1




      3. Of course, nothing is found, so an exception is thrown. The actual error is masked by a catch-all that does nothing -- the same one described in GitHub Issue #9744

        } catch (NoSuchEntityException $e) {
        /* do nothing and just return null */
        }



      So my question is: Why would the quote not have a customer_id for the quote that the customer had created when adding products to the cart? The products still show up in the right sidebar, so the quote is still attached to their session, but for whatever reason, it lacks their customer_id after they log in.










      share|improve this question
















      In a Magento 2 store, the checkout breaks when the user successfully logs in. When the user logs in and enters their address info, they receive no shipping quotes, and an error pops up saying "cartId is a required field".



      The error is actually misleading: The underlying problem (discovered using xdebug) is that the quote table row for their cart is missing a customer_id. Instead, it has a NULL value for this field.



      This means that:




      1. Magento calls this function


        MagentoQuoteModelResourceModelQuote::loadByCustomerId($quote, $customerId)



        * For the purpose of this example, $customerId = 1;




      2. Which runs a query:


        SELECT `quote`.*
        FROM `quote`
        WHERE ( `quote`.`customer_id` = 1 )
        AND ( store_id IN ( '1' ) )
        AND ( is_active = 1 )
        ORDER BY `updated_at` DESC
        LIMIT 1




      3. Of course, nothing is found, so an exception is thrown. The actual error is masked by a catch-all that does nothing -- the same one described in GitHub Issue #9744

        } catch (NoSuchEntityException $e) {
        /* do nothing and just return null */
        }



      So my question is: Why would the quote not have a customer_id for the quote that the customer had created when adding products to the cart? The products still show up in the right sidebar, so the quote is still attached to their session, but for whatever reason, it lacks their customer_id after they log in.







      magento2 checkout quote






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 19 '17 at 19:00







      Eric Seastrand

















      asked Dec 19 '17 at 18:45









      Eric SeastrandEric Seastrand

      641717




      641717





      bumped to the homepage by Community 3 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 3 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          This issue stemmed from an exception being thrown (and masked) deep down in the quote address validation code. When the customer logs in, the quote must be re-saved to set their customer_id, and before saving, it must be validated. If the validation doesn't pass, the quote isn't saved, and so the customer_id field never gets populated, leading to the error mentioned in the question.



          This exception was being thrown because there was an include path (/usr/share/php) being added by the php/apache configuration, but due to open_basedir restrictions, it wasn't accessible. As a result, when the auto-loader tried to find the MagentoFrameworkValidatorEmailAddress.php class there, it encountered a warning (shown below).

          Warning: is_readable(): open_basedir restriction in effect. File(/usr/share/php/Zend/Validate/MagentoFrameworkValidatorEmailAddress.php) is not within the allowed path(s) : [my paths] in /mnt/www/magento2-documentroot/vendor/magento/zendframework1/library/Zend/Loader.php on line 186' (length=466)



          It's still not immediately evident to me why this warning caused an exception to be thrown, but the fix ended up being extremely simple: Just add this line to .htaccess to reset the include path, and prevent the auto-loader from looking in places it has no business looking in:




          php_value include_path "."



          From what I can tell, Magento 2 is self-contained, and adds its own relevant paths to the include path, so there shouldn't be any need for other include paths. If this is incorrect (or changes at a later date), please let me know in the comments.






          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%2f206439%2fmagento-2-has-null-value-for-customer-id-in-the-quotes-table-even-after-the-cus%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














            This issue stemmed from an exception being thrown (and masked) deep down in the quote address validation code. When the customer logs in, the quote must be re-saved to set their customer_id, and before saving, it must be validated. If the validation doesn't pass, the quote isn't saved, and so the customer_id field never gets populated, leading to the error mentioned in the question.



            This exception was being thrown because there was an include path (/usr/share/php) being added by the php/apache configuration, but due to open_basedir restrictions, it wasn't accessible. As a result, when the auto-loader tried to find the MagentoFrameworkValidatorEmailAddress.php class there, it encountered a warning (shown below).

            Warning: is_readable(): open_basedir restriction in effect. File(/usr/share/php/Zend/Validate/MagentoFrameworkValidatorEmailAddress.php) is not within the allowed path(s) : [my paths] in /mnt/www/magento2-documentroot/vendor/magento/zendframework1/library/Zend/Loader.php on line 186' (length=466)



            It's still not immediately evident to me why this warning caused an exception to be thrown, but the fix ended up being extremely simple: Just add this line to .htaccess to reset the include path, and prevent the auto-loader from looking in places it has no business looking in:




            php_value include_path "."



            From what I can tell, Magento 2 is self-contained, and adds its own relevant paths to the include path, so there shouldn't be any need for other include paths. If this is incorrect (or changes at a later date), please let me know in the comments.






            share|improve this answer




























              0














              This issue stemmed from an exception being thrown (and masked) deep down in the quote address validation code. When the customer logs in, the quote must be re-saved to set their customer_id, and before saving, it must be validated. If the validation doesn't pass, the quote isn't saved, and so the customer_id field never gets populated, leading to the error mentioned in the question.



              This exception was being thrown because there was an include path (/usr/share/php) being added by the php/apache configuration, but due to open_basedir restrictions, it wasn't accessible. As a result, when the auto-loader tried to find the MagentoFrameworkValidatorEmailAddress.php class there, it encountered a warning (shown below).

              Warning: is_readable(): open_basedir restriction in effect. File(/usr/share/php/Zend/Validate/MagentoFrameworkValidatorEmailAddress.php) is not within the allowed path(s) : [my paths] in /mnt/www/magento2-documentroot/vendor/magento/zendframework1/library/Zend/Loader.php on line 186' (length=466)



              It's still not immediately evident to me why this warning caused an exception to be thrown, but the fix ended up being extremely simple: Just add this line to .htaccess to reset the include path, and prevent the auto-loader from looking in places it has no business looking in:




              php_value include_path "."



              From what I can tell, Magento 2 is self-contained, and adds its own relevant paths to the include path, so there shouldn't be any need for other include paths. If this is incorrect (or changes at a later date), please let me know in the comments.






              share|improve this answer


























                0












                0








                0







                This issue stemmed from an exception being thrown (and masked) deep down in the quote address validation code. When the customer logs in, the quote must be re-saved to set their customer_id, and before saving, it must be validated. If the validation doesn't pass, the quote isn't saved, and so the customer_id field never gets populated, leading to the error mentioned in the question.



                This exception was being thrown because there was an include path (/usr/share/php) being added by the php/apache configuration, but due to open_basedir restrictions, it wasn't accessible. As a result, when the auto-loader tried to find the MagentoFrameworkValidatorEmailAddress.php class there, it encountered a warning (shown below).

                Warning: is_readable(): open_basedir restriction in effect. File(/usr/share/php/Zend/Validate/MagentoFrameworkValidatorEmailAddress.php) is not within the allowed path(s) : [my paths] in /mnt/www/magento2-documentroot/vendor/magento/zendframework1/library/Zend/Loader.php on line 186' (length=466)



                It's still not immediately evident to me why this warning caused an exception to be thrown, but the fix ended up being extremely simple: Just add this line to .htaccess to reset the include path, and prevent the auto-loader from looking in places it has no business looking in:




                php_value include_path "."



                From what I can tell, Magento 2 is self-contained, and adds its own relevant paths to the include path, so there shouldn't be any need for other include paths. If this is incorrect (or changes at a later date), please let me know in the comments.






                share|improve this answer













                This issue stemmed from an exception being thrown (and masked) deep down in the quote address validation code. When the customer logs in, the quote must be re-saved to set their customer_id, and before saving, it must be validated. If the validation doesn't pass, the quote isn't saved, and so the customer_id field never gets populated, leading to the error mentioned in the question.



                This exception was being thrown because there was an include path (/usr/share/php) being added by the php/apache configuration, but due to open_basedir restrictions, it wasn't accessible. As a result, when the auto-loader tried to find the MagentoFrameworkValidatorEmailAddress.php class there, it encountered a warning (shown below).

                Warning: is_readable(): open_basedir restriction in effect. File(/usr/share/php/Zend/Validate/MagentoFrameworkValidatorEmailAddress.php) is not within the allowed path(s) : [my paths] in /mnt/www/magento2-documentroot/vendor/magento/zendframework1/library/Zend/Loader.php on line 186' (length=466)



                It's still not immediately evident to me why this warning caused an exception to be thrown, but the fix ended up being extremely simple: Just add this line to .htaccess to reset the include path, and prevent the auto-loader from looking in places it has no business looking in:




                php_value include_path "."



                From what I can tell, Magento 2 is self-contained, and adds its own relevant paths to the include path, so there shouldn't be any need for other include paths. If this is incorrect (or changes at a later date), please let me know in the comments.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 21 '17 at 14:06









                Eric SeastrandEric Seastrand

                641717




                641717






























                    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%2f206439%2fmagento-2-has-null-value-for-customer-id-in-the-quotes-table-even-after-the-cus%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

                    迭戈·戈丁...

                    A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

                    1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...