I have installed Magento 1.8.0 and on localhost the cart is working correctly. I change the quantity of a product in the cart then I push the "Update cart" button and all works fine. I trasferred the site online and the cart quantity doesn't work anymore. As I change the quantity of a product and click the button the quantity remains the same. If I go back and try to add the same product to the cart, even if I specify a different quantity like 10 and not 1, in the cart only 1 item is added every time I click on "add to the cart" button and not 10 as specified. I cannot figure out where's the problem. I excluded my custom theme and rolled back to the default theme and the problem persist. I updated magento to 1.8.1 and the same problem.
4 Answers
In your theme directory
In your /app/design/frontend/yourthemepackage/default/template/checkout/cart.phtml file or /app/design/frontend/default/yourtheme/template/checkout/cart.phtml file
Just place on line 50 just after getUrl('checkout/cart/updatePost') ?>" method="post"> paste the below code
<?php echo $this->getBlockHtml('formkey'); ?>
it will work fine now.
P.S. for more information you can check same answer on http://magento-online-tutorials.blogspot.in/2015/11/shopping-cart-quantity-not-able-to.html
Those who have upgraded their Magento to 1.8 must have following line in
app\design\frontend\default\customtheme\template\checkout\cart.phtml
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
<?php echo $this->getBlockHtml('formkey'); ?> // this line must be there
It was a combination of two settings (System > Configuration > Web).
Change from:
Unsecure
- Base URL:
http://domain.name/
- Base Link URL:
{{unsecure_base_url}}
- Base Skin URL:
{{unsecure_base_url}}skin/
- Base Media URL:
{{unsecure_base_url}}media/
- Base JavaScript URL:
{{unsecure_base_url}}js/
Secure
- Base URL:
https://domain.name/
- Base Link URL:
{{secure_base_url}}
- Base Skin URL:
{{secure_base_url}}skin/
- Base Media URL:
{{secure_base_url}}media/
- Base JavaScript URL:
{{secure_base_url}}js/
- Use Secure URLs in Frontend:
YES
- Use Secure URLs in Admin:
YES
to :
Unsecure
- Base URL:
https://domain.name/
- Base Link URL:
{{secure_base_url}}
- Base Skin URL:
{{secure_base_url}}skin/
- Base Media URL:
{{secure_base_url}}media/
- Base JavaScript URL:
{{secure_base_url}}js/
Secure
- Base URL:
https://domain.name/
- Base Link URL:
{{secure_base_url}}
- Base Skin URL:
{{secure_base_url}}skin/
- Base Media URL:
{{secure_base_url}}media/
- Base JavaScript URL:
{{secure_base_url}}js/
- Use Secure URLs in Frontend:
YES
- Use Secure URLs in Admin:
YES
And, finally, do not forget to add this:
<?php echo $this->getBlockHtml('formkey'); ?>
at line 57 in file ../template/checkout/cart.phtml
The second setting works for Magento 1.8.1.
I'm pretty sure that for Magento 1.8.0, the first setting for my domain hosted on secure HTTPS protocol would be sufficient.
It seems weird but it seems that the cookies used by the cart have problems when using the first site configuration.
Or maybe it's a redirect issue.
You have to pass form key in cart.phtml file to solve this issue.
app\design\frontend\yourpackage\yourtheme\template\checkout\cart.phtml
You can pass form key by
<?php echo $this->getBlockHtml('formkey'); ?>
after form tag.
It will be like
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
<?php echo $this->getBlockHtml('formkey'); ?>
Or before submit button in same file
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" >