6

I want summary count in .phtml file with cache enable.

Sukumar Gorai
  • 10,823
  • 4
  • 19
  • 46
M2 Dev
  • 73
  • 8

1 Answers1

9

You should get it with customer data. You can try to add the following code in your phtml file.

<script type="text/javascript">
    require([
        'Magento_Customer/js/customer-data'
    ], function (customerData) {
        'use strict';

        customerData.get('cart').subscribe(function (cartInfo) {
            console.log(cartInfo['summary_count']);
        }, this);
    });
</script>
Biren Patel
  • 940
  • 7
  • 28