How to get quote details in helperDetach quote from customer sessionproblem unsetting quote (cart), data is not savedHow to set customer id for a quote in Magento?Replacing current quote with a stored QuoteNot getting updated merge quote id using customer_login observerHow to get the billing address from a quote instance: Magento 2How to get the order items and quote items whenever create order from admin panel?Removing items from quote depending on custom conditionMagento 2 Session getting reset after placing orderGet Quote Item from Product Id

Movie about a boy who was born old and grew young

Do simulator games use a realistic trajectory to get into orbit?

Basic question about swap/swap spreads

What is the advantage of carrying a tripod and ND-filters when you could use image stacking instead?

Remove sudoers using script

Do the English have an ancient (obsolete) verb for the action of the book opening?

Payment instructions from HomeAway look fishy to me

After the loss of Challenger, why weren’t Galileo and Ulysses launched by Centaurs on expendable boosters?

Cause of continuous spectral lines

Strange symbol for two functions

When conversion from Integer to Single may lose precision

Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut

SF novella separating the dumb majority from the intelligent part of mankind

Avoiding cliches when writing gods

Does the "6 seconds per round" rule apply to speaking/roleplaying during combat situations?

Notation of last measure of a song with a pickup measure

Trapping Rain Water

What LISP compilers and interpreters were available for 8-bit machines?

Can a user sell my software (MIT license) without modification?

Does an ice chest packed full of frozen food need ice?

Translating 'Liber'

How many times can you cast a card exiled by Release to the Wind?

Can you really not move between grapples/shoves?

Russian equivalents of "no love lost"



How to get quote details in helper


Detach quote from customer sessionproblem unsetting quote (cart), data is not savedHow to set customer id for a quote in Magento?Replacing current quote with a stored QuoteNot getting updated merge quote id using customer_login observerHow to get the billing address from a quote instance: Magento 2How to get the order items and quote items whenever create order from admin panel?Removing items from quote depending on custom conditionMagento 2 Session getting reset after placing orderGet Quote Item from Product Id






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








0















I want to see if there is anything exists in the cart if I am in a phtml page



I have tried to use session and cart but I am getting null
When I tried to use session I wasn’t sure how to get the quote ID in order to get cart ID but I don’t know which is the right approach to take
Could anyone help me out with this










share|improve this question




























    0















    I want to see if there is anything exists in the cart if I am in a phtml page



    I have tried to use session and cart but I am getting null
    When I tried to use session I wasn’t sure how to get the quote ID in order to get cart ID but I don’t know which is the right approach to take
    Could anyone help me out with this










    share|improve this question
























      0












      0








      0








      I want to see if there is anything exists in the cart if I am in a phtml page



      I have tried to use session and cart but I am getting null
      When I tried to use session I wasn’t sure how to get the quote ID in order to get cart ID but I don’t know which is the right approach to take
      Could anyone help me out with this










      share|improve this question














      I want to see if there is anything exists in the cart if I am in a phtml page



      I have tried to use session and cart but I am getting null
      When I tried to use session I wasn’t sure how to get the quote ID in order to get cart ID but I don’t know which is the right approach to take
      Could anyone help me out with this







      cart session quote quoteitem






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 28 at 19:09









      Jack BrooksJack Brooks

      356




      356




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Something like this should work



          app/code/Xigen/Cart/Helper/Quote.php



          namespace XigenCartHelper;

          use MagentoFrameworkAppHelperAbstractHelper;

          class Quote extends AbstractHelper


          /**
          * @param MagentoFrameworkAppHelperContext $context
          */
          public function __construct(
          MagentoFrameworkAppHelperContext $context,
          MagentoCheckoutModelCart $cart
          )
          $this->cart = $cart;
          parent::__construct($context);


          public function getAllVisibleItems()
          return $this->cart->getQuote()->getAllVisibleItems();


          public function getAllVisibleItemsCount()
          return count($this->getAllVisibleItems());




          Then in template for example



          $visibleItems = $this->helper('XigenCartHelperQuote')->getAllVisibleItemsCount();






          share|improve this answer























          • How does it know to take the active cart? I mean for each customer a different cart.

            – vitoriodachef
            May 28 at 20:35






          • 1





            It's always only the cart of the current session. Unless the block is cached of course.

            – Dominic Xigen
            May 28 at 20:43






          • 1





            I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

            – Jack Brooks
            May 28 at 20:46











          • @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

            – Jack Brooks
            May 29 at 19:31











          • Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

            – Dominic Xigen
            May 29 at 20:27











          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%2f276467%2fhow-to-get-quote-details-in-helper%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














          Something like this should work



          app/code/Xigen/Cart/Helper/Quote.php



          namespace XigenCartHelper;

          use MagentoFrameworkAppHelperAbstractHelper;

          class Quote extends AbstractHelper


          /**
          * @param MagentoFrameworkAppHelperContext $context
          */
          public function __construct(
          MagentoFrameworkAppHelperContext $context,
          MagentoCheckoutModelCart $cart
          )
          $this->cart = $cart;
          parent::__construct($context);


          public function getAllVisibleItems()
          return $this->cart->getQuote()->getAllVisibleItems();


          public function getAllVisibleItemsCount()
          return count($this->getAllVisibleItems());




          Then in template for example



          $visibleItems = $this->helper('XigenCartHelperQuote')->getAllVisibleItemsCount();






          share|improve this answer























          • How does it know to take the active cart? I mean for each customer a different cart.

            – vitoriodachef
            May 28 at 20:35






          • 1





            It's always only the cart of the current session. Unless the block is cached of course.

            – Dominic Xigen
            May 28 at 20:43






          • 1





            I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

            – Jack Brooks
            May 28 at 20:46











          • @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

            – Jack Brooks
            May 29 at 19:31











          • Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

            – Dominic Xigen
            May 29 at 20:27















          0














          Something like this should work



          app/code/Xigen/Cart/Helper/Quote.php



          namespace XigenCartHelper;

          use MagentoFrameworkAppHelperAbstractHelper;

          class Quote extends AbstractHelper


          /**
          * @param MagentoFrameworkAppHelperContext $context
          */
          public function __construct(
          MagentoFrameworkAppHelperContext $context,
          MagentoCheckoutModelCart $cart
          )
          $this->cart = $cart;
          parent::__construct($context);


          public function getAllVisibleItems()
          return $this->cart->getQuote()->getAllVisibleItems();


          public function getAllVisibleItemsCount()
          return count($this->getAllVisibleItems());




          Then in template for example



          $visibleItems = $this->helper('XigenCartHelperQuote')->getAllVisibleItemsCount();






          share|improve this answer























          • How does it know to take the active cart? I mean for each customer a different cart.

            – vitoriodachef
            May 28 at 20:35






          • 1





            It's always only the cart of the current session. Unless the block is cached of course.

            – Dominic Xigen
            May 28 at 20:43






          • 1





            I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

            – Jack Brooks
            May 28 at 20:46











          • @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

            – Jack Brooks
            May 29 at 19:31











          • Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

            – Dominic Xigen
            May 29 at 20:27













          0












          0








          0







          Something like this should work



          app/code/Xigen/Cart/Helper/Quote.php



          namespace XigenCartHelper;

          use MagentoFrameworkAppHelperAbstractHelper;

          class Quote extends AbstractHelper


          /**
          * @param MagentoFrameworkAppHelperContext $context
          */
          public function __construct(
          MagentoFrameworkAppHelperContext $context,
          MagentoCheckoutModelCart $cart
          )
          $this->cart = $cart;
          parent::__construct($context);


          public function getAllVisibleItems()
          return $this->cart->getQuote()->getAllVisibleItems();


          public function getAllVisibleItemsCount()
          return count($this->getAllVisibleItems());




          Then in template for example



          $visibleItems = $this->helper('XigenCartHelperQuote')->getAllVisibleItemsCount();






          share|improve this answer













          Something like this should work



          app/code/Xigen/Cart/Helper/Quote.php



          namespace XigenCartHelper;

          use MagentoFrameworkAppHelperAbstractHelper;

          class Quote extends AbstractHelper


          /**
          * @param MagentoFrameworkAppHelperContext $context
          */
          public function __construct(
          MagentoFrameworkAppHelperContext $context,
          MagentoCheckoutModelCart $cart
          )
          $this->cart = $cart;
          parent::__construct($context);


          public function getAllVisibleItems()
          return $this->cart->getQuote()->getAllVisibleItems();


          public function getAllVisibleItemsCount()
          return count($this->getAllVisibleItems());




          Then in template for example



          $visibleItems = $this->helper('XigenCartHelperQuote')->getAllVisibleItemsCount();







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 28 at 20:17









          Dominic XigenDominic Xigen

          92511




          92511












          • How does it know to take the active cart? I mean for each customer a different cart.

            – vitoriodachef
            May 28 at 20:35






          • 1





            It's always only the cart of the current session. Unless the block is cached of course.

            – Dominic Xigen
            May 28 at 20:43






          • 1





            I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

            – Jack Brooks
            May 28 at 20:46











          • @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

            – Jack Brooks
            May 29 at 19:31











          • Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

            – Dominic Xigen
            May 29 at 20:27

















          • How does it know to take the active cart? I mean for each customer a different cart.

            – vitoriodachef
            May 28 at 20:35






          • 1





            It's always only the cart of the current session. Unless the block is cached of course.

            – Dominic Xigen
            May 28 at 20:43






          • 1





            I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

            – Jack Brooks
            May 28 at 20:46











          • @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

            – Jack Brooks
            May 29 at 19:31











          • Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

            – Dominic Xigen
            May 29 at 20:27
















          How does it know to take the active cart? I mean for each customer a different cart.

          – vitoriodachef
          May 28 at 20:35





          How does it know to take the active cart? I mean for each customer a different cart.

          – vitoriodachef
          May 28 at 20:35




          1




          1





          It's always only the cart of the current session. Unless the block is cached of course.

          – Dominic Xigen
          May 28 at 20:43





          It's always only the cart of the current session. Unless the block is cached of course.

          – Dominic Xigen
          May 28 at 20:43




          1




          1





          I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

          – Jack Brooks
          May 28 at 20:46





          I was about to say the session as well. @DominicXigen thank you for this I will take a look at this and get back to you. Thanks for showing the count part

          – Jack Brooks
          May 28 at 20:46













          @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

          – Jack Brooks
          May 29 at 19:31





          @DominicXigen hi there. I have tried this it worked for maybe once like it did work but then when I refresh the page it won’t come up like it’s null but my cart has product

          – Jack Brooks
          May 29 at 19:31













          Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

          – Dominic Xigen
          May 29 at 20:27





          Can you disable frontend caches and see if still the same php bin/magento cache:disable layout block_html full_page

          – Dominic Xigen
          May 29 at 20:27

















          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%2f276467%2fhow-to-get-quote-details-in-helper%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