Question

I ran into a issue where i could add products to cart and i got success message too but the minicart is not updating with the added items.

I got below error in console, I have upgraded the magento to 2.1.0

TypeError: cart is not a function in knockout.js

Did anyone came across this issue.

Was it helpful?

Solution

I have updated the bind events in the minicart file by comparing the base codes, once after update. It worked. Just compare the minicart.phtml file from theme

app\design\frontend\Theme_namespace\Theme_module\Magento_Ch‌​eckout\templates\car‌​t

with core template

vendor\magento\module-checkout\view\frontend\templates\cart‌

​In these two files class and bind events may be different in your theme, that is why it is not updating.

OTHER TIPS

If you're working with Porto theme or 3rd theme. You need one more step : replace content.html of porto theme with core content.html file to make it works.

Three steps which I solved this problem:

  1. Replace the minicart.phtml file from theme (app\design\frontend\Theme_namespace\Theme_module\Magento_Ch‌​eckout\templates\car‌​t) with core template (vendor\magento\module-checkout\view\frontend\templates\cart‌​).
  2. Replace content.html file from your theme (app\design\frontend\Theme_namespace\Theme_module\Magento_Checkout\web\template\minicart\content.html) with core template (vendor\magento\module-checkout\view\frontend\web\template\minicart\content.html)
  3. Remove all pub/static/frontend , remove var folder. Run deploy static content again : php magento setup:static-content:deploy

Result minicart after fixed

The function cart() was replaced with getCartParam() in 2.1.5 version, so for example, cart().summary_count becomes getCartParam('summary_count')

The function cart() was replaced with getCartParam(), so for example, cart().summary_count becomes getCartParam('summary_count'). You can download the files in this post http://iddema.com/porto-theme-cart-is-not-function/

Files http://iddema.com/wp-content/uploads/2018/01/Smartwave.zip

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top