Skip to main content

Can’t able to update cart quantities after upgrade Magento

Please go through the below for making the cart quantities work in Magento.

Another issue which has cropped up on a number of clients’ sites after an upgrade to Magento 1.8 is that they can’t update cart quantities any more. The functionality still appears to be there – you change product quantities and hit the “update basket” button – but it doesn’t actually do anything.
If this is happening to you, the chances are that you’re using a custom template file for template/checkout/cart.phtml in your theme – with the recent upgrade a small change has been introduced to the base version of this file which, since you’re using a custom version, won’t be reflected in your page.
One approach is simply to delete the cart.phtml file, which forces Magento to fall back on the base file – but if you’ve got a custom version of that file the chances are you’ve made some changes to it, which would be wiped out if you went down this route.
The better approach is to add the updated lines to your own cart.phtml file – to fix the specific issue at hand there are two additions which need to be made :
Towards the top of the file, find the line :

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

and after it add in this line :

<?php echo $this->getChildHtml('form_before') ?>

Shortly after that, look for the line :

<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>"
 method="post">
and check that after it there is the following line :

<?php echo $this->getBlockHtml('formkey'); ?>

If not, add it in.
Then, further down the file, look for the code which outputs your “clear shopping cart” button – if you’ve not customised your installation, this should look something like this :

<button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>

Immediately after it, paste the following lines :

                            <!--[if lt IE 8]>
                            <input type="hidden" id="update_cart_action_container" />
                            <script type="text/javascript">
                            //<![CDATA[
                                Event.observe(window, 'load', function()
                                {
                                    // Internet Explorer (lt 8) does not support value attribute in button elements
                                    $emptyCartButton = $('empty_cart_button');
                                    $cartActionContainer = $('update_cart_action_container');
                                    if ($emptyCartButton && $cartActionContainer) {
                                        Event.observe($emptyCartButton, 'click', function()
                                        {
                                            $emptyCartButton.setAttribute('name', 'update_cart_action_temp');
                                            $cartActionContainer.setAttribute('name', 'update_cart_action');
                                            $cartActionContainer.setValue('empty_cart');
                                        });
                                    }

                                });
                            //]]>
                            </script>
                            <![endif]-->

Save the file, upload it to your theme’s template/checkout/ folder (remember to keep a backup of your original cart.phtml) and you should be good to go!

Comments

Popular posts from this blog

Magento Form Validators

Magento Javascript Validation Classes There are many more validation classes you can assign and I list them here as a reference. For more information on this please use Google, experiment with the code or contact me via my email or the contact form. validate-select Please select an option required-entry This is a required field validate-number Please enter a valid number in this field validate-digits Please use numbers only in this field. please avoid spaces or other characters such as dots or commas validate-alpha Please use letters only (a-z or A-Z) in this field. validate-code Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter. validate-alphanum Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed validate-street Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field validate-phoneStrict

How to create Guest Wishlist For Magento

Add to wishlist without customer login Add three tables CREATE TABLE `wishlist` ( `wishlist_id` INT(11) NOT NULL AUTO_INCREMENT, `customer_id` INT(11) NULL DEFAULT NULL, `shared` INT(11) NULL DEFAULT NULL, `sharing_code` VARCHAR(50) NULL DEFAULT NULL, `updated_at` TIMESTAMP NULL DEFAULT NULL, `cookie` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`wishlist_id`) ) COLLATE='latin1_swedish_ci' ENGINE=InnoDB AUTO_INCREMENT=0 ; CREATE TABLE `wishlist_item` ( `wishlist_item_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Wishlist item ID', `wishlist_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Wishlist ID', `product_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Product ID', `store_id` SMALLINT(5) UNSIGNED NULL DEFAULT NULL COMMENT 'Store ID', `added_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Add date and time', `description` TEXT NULL COMMENT '